10_EnOcean.pm 860 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412
  1. ##############################################
  2. # $Id: 10_EnOcean.pm 13812 2017-03-27 04:39:32Z klaus.schauer $
  3. package main;
  4. use strict;
  5. use warnings;
  6. my $cryptFunc;
  7. eval "use Crypt::Rijndael";
  8. if ($@) {
  9. $cryptFunc = 0;
  10. } else {
  11. $cryptFunc = 1;
  12. }
  13. eval "use Crypt::Random qw(makerandom)";
  14. if ($@) {
  15. $cryptFunc = 0;
  16. } else {
  17. $cryptFunc = $cryptFunc == 1 ? 1 : 0;
  18. }
  19. use SetExtensions;
  20. sub EnOcean_Define($$);
  21. sub EnOcean_Initialize($);
  22. sub EnOcean_Parse($$);
  23. sub EnOcean_Get($@);
  24. sub EnOcean_Set($@);
  25. sub EnOcean_hvac_01Cmd($$$);
  26. sub EnOcean_roomCtrlPanel_00Snd($$$$$$$$);
  27. sub EnOcean_CheckSenderID($$$);
  28. sub EnOcean_SndRadio($$$$$$$$);
  29. sub EnOcean_ReadingScaled($$$$);
  30. sub EnOcean_TimerSet($);
  31. sub EnOcean_Undef($$);
  32. my %EnO_rorgname = (
  33. "A5" => "4BS", # 4BS, org 07
  34. "A6" => "ADT", # adressing destination telegram
  35. "A7" => "SMREC", # Smart Ack Relaim
  36. "B0" => "GPTI", # GP teach-in request
  37. "B1" => "GPTR", # GP teach-in response
  38. "B2" => "GPCD", # GP complete data
  39. "B3" => "GPSD", # GP selective data
  40. "C5" => "SYSEX", # remote management >> packet type 7 used
  41. "C6" => "SMLRNREQ", # Smart Ack Learn Request
  42. "C7" => "SMLRNANS", # Smart Ack Learn Answer
  43. "D0" => "SMMBOX", # Smart Ack Mail Box Functions
  44. "D1" => "MSC", # MSC
  45. "D2" => "VLD", # VLD
  46. "D4" => "UTE", # UTE
  47. "D5" => "contact", # 1BS, org 06
  48. "F6" => "switch", # RPS, org 05
  49. "30" => "SEC", # secure telegram
  50. "31" => "ENC", # secure telegram with encapsulation
  51. "32" => "SECD", # decrypted secure telegram
  52. "35" => "STE", # secure Teach-In
  53. "40" => "CDM", # chained data message
  54. );
  55. # switch commands
  56. my @EnO_ptm200btn = ("AI", "A0", "BI", "B0", "CI", "C0", "DI", "D0");
  57. my %EnO_ptm200btn;
  58. # switch.00 commands
  59. my %EnO_switch_00Btn = (
  60. "A0" => 14,
  61. "AI" => 13,
  62. "B0" => 12,
  63. "BI" => 11,
  64. "A0,B0" => 7,
  65. "A0,BI" => 10,
  66. "AI,B0" => 5,
  67. "AI,BI" => 9,
  68. "pressed" => 8,
  69. "pressed34" => 6,
  70. "released" => 15,
  71. "teachInSec" => 253,
  72. "teachOut" => 254,
  73. "teachIn" => 255
  74. );
  75. # gateway commands
  76. my @EnO_gwCmd = ("switching", "dimming", "setpointShift", "setpointBasic", "controlVar", "fanStage", "blindCmd");
  77. my %EnO_gwCmd = (
  78. "switching" => 1,
  79. "dimming" => 2,
  80. "setpointShift" => 3,
  81. "setpointBasic" => 4,
  82. "controlVar" => 5,
  83. "fanStage" => 6,
  84. "blindCmd" => 7,
  85. );
  86. # Some Manufacturers (e.g. Jaeger Direkt) also sell EnOcean products without an entry in the table below.
  87. my %EnO_manuf = (
  88. "000" => "Reserved",
  89. "001" => "Peha",
  90. "002" => "Thermokon",
  91. "003" => "Servodan",
  92. "004" => "EchoFlex Solutions",
  93. "005" => "AWAG Elektrotechnik AG (Omnio)",
  94. "006" => "Hardmeier electronics",
  95. "007" => "Regulvar Inc",
  96. "008" => "Ad Hoc Electronics",
  97. "009" => "Distech Controls",
  98. "00A" => "Kieback + Peter",
  99. "00B" => "EnOcean GmbH",
  100. "00C" => "Probare",
  101. "00D" => "Eltako",
  102. "00E" => "Leviton",
  103. "00F" => "Honeywell",
  104. "010" => "Spartan Peripheral Devices",
  105. "011" => "Siemens",
  106. "012" => "T-Mac",
  107. "013" => "Reliable Controls Corporation",
  108. "014" => "Elsner Elektronik GmbH",
  109. "015" => "Diehl Controls",
  110. "016" => "BSC Computer",
  111. "017" => "S+S Regeltechnik GmbH",
  112. "018" => "Masco Corporation",
  113. "019" => "Intesis Software SL",
  114. "01A" => "Viessmann",
  115. "01B" => "Lutuo Technology",
  116. "01C" => "Schneider Electric",
  117. "01D" => "Sauter",
  118. "01E" => "Boot-Up",
  119. "01F" => "Osram Sylvania",
  120. "020" => "Unotech",
  121. "021" => "Delta Controls Inc",
  122. "022" => "Unitronic AG",
  123. "023" => "NanoSense",
  124. "024" => "The S4 Group",
  125. "025" => "MSR Solutions",
  126. "026" => "GE",
  127. "027" => "Maico",
  128. "028" => "Ruskin Company",
  129. "029" => "Magnum Engery Solutions",
  130. "02A" => "KM Controls",
  131. "02B" => "Ecologix Controls",
  132. "02C" => "Trio 2 Sys",
  133. "02D" => "Afriso-Euro-Index",
  134. "030" => "NEC AccessTechnica Ltd",
  135. "031" => "ITEC Corporation",
  136. "032" => "Simix Co Ltd",
  137. "033" => "Permundo GmbH",
  138. "034" => "Eurotronic Technology GmbH",
  139. "035" => "Art Japan Co Ltd",
  140. "036" => "Tiansu Automation Control System Co Ltd",
  141. "038" => "Gruppo Giordano Idea Spa",
  142. "039" => "alphaEOS AG",
  143. "03A" => "Tag Technologies",
  144. "03C" => "Cloud Buildings Ltd",
  145. "03E" => "GIGA Concept",
  146. "03F" => "Sensortec",
  147. "040" => "Jaeger Direkt",
  148. "041" => "Air System Components Inc",
  149. "043" => "SODA GmbH",
  150. "045" => "Holter",
  151. "046" => "ID-RF",
  152. "049" => "Micropelt GmbH",
  153. "7FF" => "Multi user Manufacturer ID",
  154. );
  155. my %EnO_eepConfig = (
  156. "A5.02.01" => {attr => {subType => "tempSensor.01"}, GPLOT => "EnO_temp4:Temp,"},
  157. "A5.02.02" => {attr => {subType => "tempSensor.02"}, GPLOT => "EnO_temp4:Temp,"},
  158. "A5.02.03" => {attr => {subType => "tempSensor.03"}, GPLOT => "EnO_temp4:Temp,"},
  159. "A5.02.04" => {attr => {subType => "tempSensor.04"}, GPLOT => "EnO_temp4:Temp,"},
  160. "A5.02.05" => {attr => {subType => "tempSensor.05"}, GPLOT => "EnO_temp4:Temp,"},
  161. "A5.02.06" => {attr => {subType => "tempSensor.06"}, GPLOT => "EnO_temp4:Temp,"},
  162. "A5.02.07" => {attr => {subType => "tempSensor.07"}, GPLOT => "EnO_temp4:Temp,"},
  163. "A5.02.08" => {attr => {subType => "tempSensor.08"}, GPLOT => "EnO_temp4:Temp,"},
  164. "A5.02.09" => {attr => {subType => "tempSensor.09"}, GPLOT => "EnO_temp4:Temp,"},
  165. "A5.02.0A" => {attr => {subType => "tempSensor.0A"}, GPLOT => "EnO_temp4:Temp,"},
  166. "A5.02.0B" => {attr => {subType => "tempSensor.0B"}, GPLOT => "EnO_temp4:Temp,"},
  167. "A5.02.10" => {attr => {subType => "tempSensor.10"}, GPLOT => "EnO_temp4:Temp,"},
  168. "A5.02.11" => {attr => {subType => "tempSensor.11"}, GPLOT => "EnO_temp4:Temp,"},
  169. "A5.02.12" => {attr => {subType => "tempSensor.12"}, GPLOT => "EnO_temp4:Temp,"},
  170. "A5.02.13" => {attr => {subType => "tempSensor.13"}, GPLOT => "EnO_temp4:Temp,"},
  171. "A5.02.14" => {attr => {subType => "tempSensor.14"}, GPLOT => "EnO_temp4:Temp,"},
  172. "A5.02.15" => {attr => {subType => "tempSensor.15"}, GPLOT => "EnO_temp4:Temp,"},
  173. "A5.02.16" => {attr => {subType => "tempSensor.16"}, GPLOT => "EnO_temp4:Temp,"},
  174. "A5.02.17" => {attr => {subType => "tempSensor.17"}, GPLOT => "EnO_temp4:Temp,"},
  175. "A5.02.18" => {attr => {subType => "tempSensor.18"}, GPLOT => "EnO_temp4:Temp,"},
  176. "A5.02.19" => {attr => {subType => "tempSensor.19"}, GPLOT => "EnO_temp4:Temp,"},
  177. "A5.02.1A" => {attr => {subType => "tempSensor.1A"}, GPLOT => "EnO_temp4:Temp,"},
  178. "A5.02.1B" => {attr => {subType => "tempSensor.1B"}, GPLOT => "EnO_temp4:Temp,"},
  179. "A5.02.20" => {attr => {subType => "tempSensor.20"}, GPLOT => "EnO_temp4:Temp,"},
  180. "A5.02.30" => {attr => {subType => "tempSensor.30"}, GPLOT => "EnO_temp4:Temp,"},
  181. "A5.04.01" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  182. "A5.04.02" => {attr => {subType => "tempHumiSensor.02"}, GPLOT => "EnO_temp4humi6:Temp/Humi,EnO_voltage4:Voltage,"},
  183. "A5.04.03" => {attr => {subType => "tempHumiSensor.03"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  184. "A5.05.01" => {attr => {subType => "baroSensor.01"}, GPLOT => "EnO_airPressure4:Airpressure,"},
  185. "A5.06.01" => {attr => {subType => "lightSensor.01"}, GPLOT => "EnO_brightness4:Brightness,EnO_voltage4:Voltage,"},
  186. "A5.06.02" => {attr => {subType => "lightSensor.02"}, GPLOT => "EnO_brightness4:Brightness,EnO_voltage4:Voltage,"},
  187. "A5.06.03" => {attr => {subType => "lightSensor.03"}, GPLOT => "EnO_brightness4:Brightness,"},
  188. "A5.06.04" => {attr => {subType => "lightSensor.04"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,"},
  189. "A5.06.05" => {attr => {subType => "lightSensor.05"}, GPLOT => "EnO_brightness4:Brightness,EnO_voltage4:Voltage,"},
  190. "A5.07.01" => {attr => {subType => "occupSensor.01"}, GPLOT => "EnO_motion:Motion,EnO_voltage4current4:Voltage/Current,"},
  191. "A5.07.02" => {attr => {subType => "occupSensor.02"}, GPLOT => "EnO_motion:Motion4brightness4:Motion/Brightness,EnO_voltage4:Voltage,"},
  192. "A5.07.03" => {attr => {subType => "occupSensor.03"}, GPLOT => "EnO_motion:Motion4brightness4:Motion/Brightness,EnO_voltage4:Voltage,"},
  193. "A5.08.01" => {attr => {subType => "lightTempOccupSensor.01"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,EnO_voltage4:Voltage,"},
  194. "A5.08.02" => {attr => {subType => "lightTempOccupSensor.02"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,EnO_voltage4:Voltage,"},
  195. "A5.08.03" => {attr => {subType => "lightTempOccupSensor.03"}, GPLOT => "EnO_temp4brightness4:Temp/Brightness,EnO_voltage4:Voltage,"},
  196. "A5.09.01" => {attr => {subType => "COSensor.01"}, GPLOT => "EnO_A5-09-01:CO/Temp,"},
  197. "A5.09.02" => {attr => {subType => "COSensor.02"}, GPLOT => "EnO_A5-09-02:CO/Temp,EnO_voltage4:Voltage,"},
  198. "A5.09.04" => {attr => {subType => "tempHumiCO2Sensor.01"}, GPLOT => "EnO_CO2:CO2,EnO_temp4humi6:Temp/Humi,"},
  199. "A5.09.05" => {attr => {subType => "vocSensor.01"}, GPLOT => "EnO_A5-09-05:Concentration,"},
  200. "A5.09.06" => {attr => {subType => "radonSensor.01"}, GPLOT => "EnO_A5-09-06:Radon,"},
  201. "A5.09.07" => {attr => {subType => "particlesSensor.01"}, GPLOT => "EnO_A5-09-07:Particles,"},
  202. "A5.09.08" => {attr => {subType => "CO2Sensor.01"}, GPLOT => "EnO_CO2:CO2,"},
  203. "A5.09.09" => {attr => {subType => "CO2Sensor.01"}, GPLOT => "EnO_CO2:CO2,"},
  204. "A5.09.0A" => {attr => {subType => "HSensor.01"}, GPLOT => "EnO_A5-09-0A:H/Temp,EnO_voltage4:Voltage,"},
  205. "A5.09.0B" => {attr => {subType => "radiationSensor.01"}, GPLOT => "EnO_radioactivity4/Radioactivity,EnO_voltage4:Voltage,"},
  206. "A5.09.0C" => {attr => {subType => "vocSensor.01"}, GPLOT => "EnO_A5-09-05:Concentration,"},
  207. "A5.10.01" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  208. "A5.10.02" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  209. "A5.10.03" => {attr => {subType => "roomSensorControl.05", comMode => "confirm", subDef => "getNextID"}, GPLOT => "EnO_temp4:Temp,"},
  210. "A5.10.04" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  211. "A5.10.05" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  212. "A5.10.06" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  213. "A5.10.07" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  214. "A5.10.08" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  215. "A5.10.09" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  216. "A5.10.0A" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  217. "A5.10.0B" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  218. "A5.10.0C" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  219. "A5.10.0D" => {attr => {subType => "roomSensorControl.05"}, GPLOT => "EnO_temp4:Temp,"},
  220. "A5.10.10" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  221. "A5.10.11" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  222. "A5.10.12" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  223. "A5.10.13" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  224. "A5.10.14" => {attr => {subType => "roomSensorControl.01"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  225. "A5.10.15" => {attr => {subType => "roomSensorControl.02"}, GPLOT => "EnO_temp4:Temp,"},
  226. "A5.10.16" => {attr => {subType => "roomSensorControl.02"}, GPLOT => "EnO_temp4:Temp,"},
  227. "A5.10.17" => {attr => {subType => "roomSensorControl.02"}, GPLOT => "EnO_temp4:Temp,"},
  228. "A5.10.18" => {attr => {subType => "roomSensorControl.18"}, GPLOT => "EnO_temp4:Temp,"},
  229. "A5.10.19" => {attr => {subType => "roomSensorControl.19"}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  230. "A5.10.1A" => {attr => {subType => "roomSensorControl.1A"}, GPLOT => "EnO_temp4:Temp,EnO_voltage4:Voltage,"},
  231. "A5.10.1B" => {attr => {subType => "roomSensorControl.1B"}, GPLOT => "EnO_temp4:Temp,EnO_voltage4:Voltage,"},
  232. "A5.10.1C" => {attr => {subType => "roomSensorControl.1C"}, GPLOT => "EnO_temp4:Temp,"},
  233. "A5.10.1D" => {attr => {subType => "roomSensorControl.1D"}, GPLOT => "EnO_temp4humi6:Temp/Humi"},
  234. "A5.10.1E" => {attr => {subType => "roomSensorControl.1B"}, GPLOT => "EnO_temp4:Temp,"},
  235. "A5.10.1F" => {attr => {subType => "roomSensorControl.1F"}, GPLOT => "EnO_temp4:Temp,"},
  236. "A5.10.20" => {attr => {subType => "roomSensorControl.20"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  237. "A5.10.21" => {attr => {subType => "roomSensorControl.20"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  238. "A5.10.22" => {attr => {subType => "roomSensorControl.22"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  239. "A5.10.23" => {attr => {subType => "roomSensorControl.22"}, GPLOT => "EnO_temp4humi4:Temp/Humi,"},
  240. "A5.11.01" => {attr => {subType => "lightCtrlState.01"}, GPLOT => "EnO_A5-11-01:Dim/Brightness,"},
  241. "A5.11.02" => {attr => {subType => "tempCtrlState.01"}, GPLOT => "EnO_A5-11-02:SetpointTemp/ControlVar,"},
  242. "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,"},
  243. "A5.11.04" => {attr => {subType => "lightCtrlState.02", subDef => "getNextID", subTypeSet => "lightCtrl.01", webCmd => "on:off:dim:rgb"}, GPLOT => "EnO_dimFFRGB:DimRGB,"},
  244. "A5.11.05" => {attr => {subType => "switch.05"}},
  245. "A5.12.00" => {attr => {subType => "autoMeterReading.00"}, GPLOT => "EnO_A5-12-00:Value/Counter,"},
  246. "A5.12.01" => {attr => {subType => "autoMeterReading.01"}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  247. "A5.12.02" => {attr => {subType => "autoMeterReading.02"}, GPLOT => "EnO_A5-12-02:Flowrate/Consumption,"},
  248. "A5.12.03" => {attr => {subType => "autoMeterReading.03"}, GPLOT => "EnO_A5-12-03:Flowrate/Consumption,"},
  249. "A5.12.04" => {attr => {subType => "autoMeterReading.04"}, GPLOT => "EnO_A5-12-04:Weight,EnO_A5-12-04_2:Temperature/Battery,"},
  250. "A5.12.05" => {attr => {subType => "autoMeterReading.05"}, GPLOT => "EnO_A5-12-05:Amount,EnO_A5-12-05_2:Temperature/Battery,"},
  251. "A5.12.10" => {attr => {subType => "autoMeterReading.10"}, GPLOT => "EnO_A5-12-10:Current/Change,"},
  252. "A5.13.01" => {attr => {subType => "environmentApp"}, GPLOT => "EnO_A5-13-01:WindSpeed/Raining,EnO_temp4brightness4:Temp/Brightness,"},
  253. "A5.13.02" => {attr => {subType => "environmentApp"}, GPLOT => "EnO_A5-13-01:SunIntensity,"},
  254. "A5.13.03" => {attr => {subType => "environmentApp"}},
  255. "A5.13.04" => {attr => {subType => "environmentApp"}},
  256. "A5.13.05" => {attr => {subType => "environmentApp"}},
  257. "A5.13.06" => {attr => {subType => "environmentApp"}},
  258. "A5.13.07" => {attr => {subType => "windSensor.01"}, GPLOT => "EnO_A5-13-07:WindSpeed,"},
  259. "A5.13.08" => {attr => {subType => "rainSensor.01"}, GPLOT => "EnO_A5-13-08:Raining,"},
  260. "A5.13.10" => {attr => {subType => "environmentApp"}, GPLOT => "EnO_solarRadiation4:SolarRadiation,"},
  261. "A5.14.01" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  262. "A5.14.02" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  263. "A5.14.03" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  264. "A5.14.04" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  265. "A5.14.05" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  266. "A5.14.06" => {attr => {subType => "multiFuncSensor"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  267. "A5.14.07" => {attr => {subType => "doorContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  268. "A5.14.08" => {attr => {subType => "doorContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  269. "A5.14.09" => {attr => {subType => "windowContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  270. "A5.14.0A" => {attr => {subType => "windowContact"}, GPLOT => "EnO_A5-14-xx:Voltage/Brightness,EnO_A5-14-xx_2:Contact/Vibration,"},
  271. "A5.20.01" => {attr => {subType => "hvac.01", webCmd => "setpointTemp"}, GPLOT => "EnO_A5-20-01:Temp/SetpointTemp/Setpoint,EnO_A5-20-01_2:PID,"},
  272. #"A5.20.02" => {attr => {subType => "hvac.02"}},
  273. #"A5.20.03" => {attr => {subType => "hvac.03"}},
  274. "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,"},
  275. "A5.20.10" => {attr => {subType => "hvac.10", comMode => "biDir", destinationID => "unicast", subDef => "getNextID"}, GPLOT => "EnO_A5-20-10:FanSpeed,"},
  276. "A5.20.11" => {attr => {subType => "hvac.11", comMode => "biDir", destinationID => "unicast", subDef => "getNextID"}},
  277. #"A5.20.12" => {attr => {subType => "hvac.12"}},
  278. "A5.30.01" => {attr => {subType => "digitalInput.01"}, GPLOT => "EnO_A5-30-01:Contact/Battery,"},
  279. "A5.30.02" => {attr => {subType => "digitalInput.02"}, GPLOT => "EnO_A5-30-02:Contact,"},
  280. "A5.30.03" => {attr => {subType => "digitalInput.03"}, GPLOT => "EnO_A5-30-03:Contact,EnO_temp4:Temp,"},
  281. "A5.30.04" => {attr => {subType => "digitalInput.04"}, GPLOT => "EnO_A5-30-04:Contact/Digital,"},
  282. "A5.30.05" => {attr => {subType => "digitalInput.05"}, GPLOT => "EnO_A5-30-05:Contact/Voltage,"},
  283. "A5.37.01" => {attr => {subType => "energyManagement.01", webCmd => "level:max"}, GPLOT => "EnO_A5-37-01:Level,"},
  284. "A5.38.08" => {attr => {subType => "gateway"}},
  285. "A5.38.09" => {attr => {subType => "lightCtrl.01"}, GPLOT => "EnO_dimFFRGB:DimRGB,"},
  286. "A5.3F.00" => {attr => {subType => "radioLinkTest", comMode => "biDir", destinationID => "unicast", subDef => "getNextID"}},
  287. "A5.3F.7F" => {attr => {subType => "manufProfile"}},
  288. "B0.00.00" => {attr => {subType => "genericProfile"}},
  289. "C5.00.00" => {attr => {subType => "remote", manufID => "7FF"}},
  290. "D2.01.00" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  291. "D2.01.01" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  292. "D2.01.02" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  293. "D2.01.03" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,"},
  294. "D2.01.04" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  295. "D2.01.05" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  296. "D2.01.06" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  297. "D2.01.07" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  298. "D2.01.08" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  299. "D2.01.09" => {attr => {subType => "actuator.01", defaultChannel => 0, webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,EnO_power4energy4:Power/Energie,"},
  300. "D2.01.0A" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  301. "D2.01.0B" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  302. "D2.01.0C" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  303. "D2.01.0D" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  304. "D2.01.0E" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  305. "D2.01.0F" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  306. "D2.01.10" => {attr => {subType => "actuator.01", defaultChannel => 0}, GPLOT => "EnO_power4energy4:Power/Energie,"},
  307. "D2.01.11" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  308. "D2.01.12" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  309. "D2.01.13" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  310. "D2.01.14" => {attr => {subType => "actuator.01", defaultChannel => 0}},
  311. "D2.03.00" => {attr => {subType => "switch.00"}},
  312. "D2.03.10" => {attr => {subType => "windowHandle.10"}, GPLOT => "EnO_windowHandle:WindowHandle,"},
  313. "D2.05.00" => {attr => {subType => "blindsCtrl.00", webCmd => "opens:stop:closes:position"}, GPLOT => "EnO_position4angle4:Position/AnglePos,"},
  314. "D2.05.01" => {attr => {subType => "blindsCtrl.01", webCmd => "opens:stop:closes:position"}},
  315. "D2.05.02" => {attr => {subType => "blindsCtrl.00", webCmd => "opens:stop:closes:position"}, GPLOT => "EnO_position4angle4:Position/AnglePos,"},
  316. "D2.06.01" => {attr => {subType => "multisensor.01"}, GPLOT => "EnO_temp4humi4:Temp/Humi,EnO_brightness4:Brightness,"},
  317. "D2.10.00" => {attr => {subType => "roomCtrlPanel.00", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  318. "D2.10.01" => {attr => {subType => "roomCtrlPanel.00", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  319. "D2.10.02" => {attr => {subType => "roomCtrlPanel.00", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  320. "D2.11.01" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  321. "D2.11.02" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  322. "D2.11.03" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  323. "D2.11.04" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  324. "D2.11.05" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  325. "D2.11.06" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  326. "D2.11.07" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  327. "D2.11.08" => {attr => {subType => "roomCtrlPanel.01", comMode => "biDir", webCmd => "setpointTemp"}, GPLOT => "EnO_D2-10-xx:Temp/SPT/Humi,"},
  328. "D2.20.00" => {attr => {subType => "fanCtrl.00", webCmd => "fanSpeed"}, GPLOT => "EnO_fanSpeed4humi4:FanSpeed/Humi,"},
  329. "D2.32.00" => {attr => {subType => "currentClamp.00"}, GPLOT => "EnO_D2-32-xx:Current,"},
  330. "D2.32.01" => {attr => {subType => "currentClamp.01"}, GPLOT => "EnO_D2-32-xx:Current,"},
  331. "D2.32.02" => {attr => {subType => "currentClamp.02"}, GPLOT => "EnO_D2-32-xx:Current,"},
  332. "D2.40.00" => {attr => {subType => "ledCtrlState.00"}, GPLOT => "EnO_dim4:Dim,"},
  333. "D2.40.01" => {attr => {subType => "ledCtrlState.01"}, GPLOT => "EnO_dim4RGB:DimRGB,"},
  334. "D2.50.00" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  335. "D2.50.01" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  336. "D2.50.10" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  337. "D2.50.11" => {attr => {subType => "heatRecovery.00", webCmd => "ventilation"}, GPLOT => "EnO_D2-50-xx:Temp/AirQuality,EnO_D2-50-xx_2:AirFlow/FanSpeed,"},
  338. "D2.A0.01" => {attr => {subType => "valveCtrl.00", defaultChannel => 0, webCmd => "opens:closes"}, GPLOT => "EnO_valveCtrl:Valve,"},
  339. "D2.B0.51" => {attr => {subType => "liquidLeakage.51"}, GPLOT => "EnO_liquidLeakage:LiquidLeakage,"},
  340. "D5.00.01" => {attr => {subType => "contact", manufID => "7FF"}, GPLOT => "EnO_contact:Contact,"},
  341. "F6.01.01" => {attr => {subType => "switch", sensorMode => "pushbutton"}},
  342. "F6.02.01" => {attr => {subType => "switch"}},
  343. "F6.02.02" => {attr => {subType => "switch"}},
  344. "F6.02.03" => {attr => {subType => "switch"}},
  345. #"F6.02.04" => {attr => {subType => "switch.04"}},
  346. "F6.03.01" => {attr => {subType => "switch"}},
  347. "F6.03.02" => {attr => {subType => "switch"}},
  348. "F6.04.01" => {attr => {subType => "keycard"}, GPLOT => "EnO_keycard:Keycard,"},
  349. #"F6.04.02" => {attr => {subType => "keycard.02"}, GPLOT => "EnO_keycard:Keycard,"},
  350. "F6.05.00" => {attr => {subType => "windSpeed.00"}},
  351. "F6.05.01" => {attr => {subType => "liquidLeakage"}, GPLOT => "EnO_liquidLeakage:LiquidLeakage,"},
  352. "F6.05.02" => {attr => {subType => "smokeDetector.02"}},
  353. "F6.10.00" => {attr => {subType => "windowHandle"}, GPLOT => "EnO_windowHandle:WindowHandle,"},
  354. #"F6.10.01" => {attr => {subType => "windowHandle.01"}, GPLOT => "EnO_windowHandle:WindowHandle,"},
  355. "F6.3F.7F" => {attr => {subType => "switch.7F"}},
  356. # special profiles
  357. "G5.07.01" => {attr => {subType => "occupSensor.01", eep => "A5-07-01", manufID => "00D", model => 'tracker'}, GPLOT => "EnO_motion:Motion,EnO_voltage4current4:Voltage/Current,"},
  358. "G5.10.12" => {attr => {subType => "roomSensorControl.01", eep => "A5-10-12", manufID => "00D", scaleMax => 40, scaleMin => 0, scaleDecimals => 1}, GPLOT => "EnO_temp4humi6:Temp/Humi,"},
  359. "G5.38.08" => {attr => {subType => "gateway", eep => "A5-38-08", gwCmd => "dimming", manufID => "00D", webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,"},
  360. "H5.38.08" => {attr => {subType => "gateway", comMode => "confirm", eep => "A5-38-08", gwCmd => "dimming", manufID => "00D", model => "TF", teachMethod => "confirm", webCmd => "on:off:dim"}, GPLOT => "EnO_dim4:Dim,"},
  361. "G5.3F.7F" => {attr => {subType => "manufProfile", eep => "A5-3F-7F", manufID => "00D", webCmd => "opens:stop:closes"}},
  362. "H5.3F.7F" => {attr => {subType => "manufProfile", comMode => "confirm", eep => "A5-3F-7F", manufID => "00D", model => "TF", sensorMode => 'pushbutton', settingAccuracy => "high", teachMethod => "confirm", webCmd => "opens:stop:closes"}},
  363. "M5.38.08" => {attr => {subType => "gateway", eep => "A5-38-08", gwCmd => "switching", manufID => "00D", webCmd => "on:off"}},
  364. "N5.38.08" => {attr => {subType => "gateway", comMode => "confirm", eep => "A5-38-08", gwCmd => "switching", manufID => "00D", model => "TF", teachMethod => "confirm", webCmd => "on:off"}},
  365. "G5.ZZ.ZZ" => {attr => {subType => "PM101", manufID => "005"}, GPLOT => "EnO_motion:Motion,EnO_brightness4:Brightness,"},
  366. "L6.02.01" => {attr => {subType => "smokeDetector.02", eep => "F6-05-02", manufID => "00D"}},
  367. "ZZ.ZZ.ZZ" => {attr => {subType => "raw"}},
  368. );
  369. my %EnO_extendedRemoteFunctionCode = (
  370. 0x210 => "remoteLinkTableInfo", # get
  371. 0x211 => "remoteLinkTable", # get
  372. 0x212 => "remoteLinkTable", # set
  373. 0x213 => "remoteLinkTableGP", # get
  374. 0x214 => "remoteLinkTableGP", # set
  375. 0x220 => "remoteLearnMode", # set
  376. 0x221 => "remoteTeach", # set
  377. 0x224 => "remoteReset", # set
  378. 0x225 => "remoteRLT", # set
  379. 0x226 => "remoteApplyChanges", # set
  380. 0x227 => "remoteProductID", # get
  381. 0x230 => "remoteDevCfg", # get
  382. 0x231 => "remoteDevCfg", # set
  383. 0x232 => "remoteLinkCfg", # get
  384. 0x233 => "remoteLinkCfg", # set
  385. 0x240 => "remoteAck", # parse
  386. 0x250 => "remoteRepeater", # get
  387. 0x251 => "remoteRepeater", # set
  388. 0x252 => "remoteRepeaterFilter" # set
  389. );
  390. my @EnO_models = qw (
  391. other
  392. FAE14 FHK14 FHK61
  393. FSA12 FSB14 FSB61 FSB70
  394. FSM12 FSM61
  395. FT55
  396. FTS12
  397. TF
  398. OEM
  399. tracker
  400. );
  401. my @EnO_defaultChannel = ("all", "input", 0..29);
  402. my %wakeUpCycle = (
  403. 10 => 0,
  404. 60 => 1,
  405. 90 => 2,
  406. 120 => 3,
  407. 150 => 4,
  408. 180 => 5,
  409. 210 => 6,
  410. 240 => 7,
  411. 270 => 8,
  412. 300 => 9,
  413. 330 => 10,
  414. 360 => 11,
  415. 390 => 12,
  416. 420 => 13,
  417. 450 => 14,
  418. 480 => 15,
  419. 510 => 16,
  420. 540 => 17,
  421. 570 => 18,
  422. 600 => 19,
  423. 630 => 20,
  424. 660 => 21,
  425. 690 => 22,
  426. 720 => 23,
  427. 750 => 24,
  428. 780 => 25,
  429. 810 => 26,
  430. 840 => 27,
  431. 870 => 28,
  432. 900 => 29,
  433. 930 => 30,
  434. 960 => 31,
  435. 990 => 32,
  436. 1020 => 33,
  437. 1050 => 34,
  438. 1080 => 35,
  439. 1110 => 36,
  440. 1140 => 37,
  441. 1170 => 38,
  442. 1200 => 39,
  443. 1230 => 40,
  444. 1260 => 41,
  445. 1290 => 42,
  446. 1320 => 43,
  447. 1350 => 44,
  448. 1380 => 45,
  449. 1410 => 46,
  450. 1440 => 47,
  451. 1470 => 48,
  452. 1500 => 49,
  453. 10800 => 50,
  454. 21600 => 51,
  455. 32400 => 52,
  456. 43200 => 53,
  457. 54000 => 54,
  458. 64800 => 55,
  459. 75600 => 56,
  460. 86400 => 57,
  461. 97200 => 58,
  462. 108000 => 59,
  463. 118800 => 60,
  464. 129600 => 61,
  465. 140400 => 62,
  466. 151200 => 63,
  467. );
  468. my %wakeUpCycleInv = (
  469. 0 => 10,
  470. 1 => 60,
  471. 2 => 90,
  472. 3 => 120,
  473. 4 => 150,
  474. 5 => 180,
  475. 6 => 210,
  476. 7 => 240,
  477. 8 => 270,
  478. 9 => 300,
  479. 10 => 330,
  480. 11 => 360,
  481. 12 => 390,
  482. 13 => 420,
  483. 14 => 450,
  484. 15 => 480,
  485. 16 => 510,
  486. 17 => 540,
  487. 18 => 570,
  488. 19 => 600,
  489. 20 => 630,
  490. 21 => 660,
  491. 22 => 690,
  492. 23 => 720,
  493. 24 => 750,
  494. 25 => 780,
  495. 26 => 810,
  496. 27 => 840,
  497. 28 => 870,
  498. 29 => 900,
  499. 30 => 930,
  500. 31 => 960,
  501. 32 => 990,
  502. 33 => 1020,
  503. 34 => 1050,
  504. 35 => 1080,
  505. 36 => 1110,
  506. 37 => 1140,
  507. 38 => 1170,
  508. 39 => 1200,
  509. 40 => 1230,
  510. 41 => 1260,
  511. 42 => 1290,
  512. 43 => 1320,
  513. 44 => 1350,
  514. 45 => 1380,
  515. 46 => 1410,
  516. 47 => 1440,
  517. 48 => 1470,
  518. 49 => 1500,
  519. 50 => 10800,
  520. 51 => 21600,
  521. 52 => 32400,
  522. 53 => 43200,
  523. 54 => 54000,
  524. 55 => 64800,
  525. 56 => 75600,
  526. 57 => 86400,
  527. 58 => 97200,
  528. 59 => 108000,
  529. 60 => 118800,
  530. 61 => 129600,
  531. 62 => 140400,
  532. 63 => 151200,
  533. );
  534. my @EnO_resolution = (1, 2, 3, 4, 5, 6, 8, 10, 12, 16, 20, 24, 32);
  535. my @EnO_scaling = (0, 1, 10, 100, 1000, 10000, 100000, 1e6, 1e7, 0.1, 0.01, 0.001, 1e-6, 1e-9);
  536. my %EnO_gpValueEnum = (
  537. 1 => {name => "multipurpose"},
  538. 2 => {name => "buildingMode", enum => {0 => "in_use", 1 => "not_used", 2 => "protection"},
  539. enumInv => {"in_use" => 0, "not_used" => 1, "protection" => 2}},
  540. 3 => {name => "occupanyMode", enum => {0 => "occupied", 1 => "standby", 2 => "not_occupied"},
  541. enumInv => {"occupied" => 0,"standby" => 1,"not_occupied" => 2}},
  542. 4 => {name => "hvacMode", enum => {0 => "auto", 1 => "comfort", 2 => "standby", 3 => "economy", 4 => "building_protection"},
  543. enumInv => {"auto" => 0, "comfort" => 1, "standby" => 2, "economy" => 3, "building_protection" => 4}},
  544. 5 => {name => "changeoverMode", enum => {0 => "auto", 1 => "cooling", 2 => "heating"},
  545. enumInv => {"auto" => 0,"cooling" => 1,"heating" => 2}},
  546. );
  547. my %EnO_gpValueFlag = (
  548. 1 => {name => "auto/man", flag => {0 => "man", 1 => "auto"},
  549. flagInv => {"man" => 0,"auto" => 1}},
  550. 2 => {name => "buttonPressed", flag => {0 => "not_pressed", 1 => "pressed"},
  551. flagInv => {"not_pressed" => 0,"pressed" => 1}},
  552. 3 => {name => "buttonChanged", flag => {0 => "no_change", 1 => "change"},
  553. flagInv => {"no_change" => 0,"change" => 1}},
  554. 4 => {name => "day/night", flag => {0 => "night", 1 => "day"},
  555. flagInv => {"night" => 0,"day" => 1}},
  556. 5 => {name => "down", flag => {0 => "no_change", 1 => "down"},
  557. flagInv => {"no_change" => 0,"down" => 1}},
  558. 6 => {name => "generalAlarm", flag => {0 => "manual", 1 => "alarm"},
  559. flagInv => {"manual" => 0,"alarm" => 1}},
  560. 7 => {name => "heat/cool", flag => {0 => "cool", 1 => "heat"},
  561. flagInv => {"cool" => 0,"heat" => 1}},
  562. 8 => {name => "high/low", flag => {0 => "low", 1 => "high"},
  563. flagInv => {"low" => 0,"high" => 1}},
  564. 9 => {name => "occupancy", flag => {0 => "unoccupied", 1 => "occupied"},
  565. flagInv => {"unoccupied" => 0,"occupied" => 1}},
  566. 10 => {name => "on/off", flag => {0 => "off", 1 => "on"},
  567. flagInv => {"off" => 0,"on" => 1}},
  568. 11 => {name => "open/closed", flag => {0 => "closed", 1 => "open"},
  569. flagInv => {"closed" => 0,"open" => 1}},
  570. 12 => {name => "powerAlarm", flag => {0 => "no_change", 1 => "alarm"},
  571. flagInv => {"no_change" => 0,"alarm" => 1}},
  572. 13 => {name => "start/stop", flag => {0 => "stop", 1 => "start"},
  573. flagInv => {"stop" => 0,"start" => 1}},
  574. 14 => {name => "up", flag => {0 => "no_change", 1 => "up"},
  575. flagInv => {"no_change" => 0,"up" => 1}},
  576. );
  577. my %EnO_gpValueData = (
  578. 1 => {name => "acceleration", unit => "m/s2"},
  579. 2 => {name => "angle", unit => "deg"},
  580. 3 => {name => "angular_velocity", unit => "rad/s"},
  581. 4 => {name => "area", unit => "m²"},
  582. 5 => {name => "concentration", unit => "ppm"},
  583. 6 => {name => "current", unit => "A"},
  584. 7 => {name => "distance", unit => "m"},
  585. 8 => {name => "electric_field_strength", unit => "V/m"},
  586. 9 => {name => "energy", unit => "J"},
  587. 10 => {name => "number", unit => "N/A"},
  588. 11 => {name => "force", unit => "N"},
  589. 12 => {name => "frequency", unit => "Hz"},
  590. 13 => {name => "heat_flux_density", unit => "W/m2"},
  591. 14 => {name => "impulse", unit => "Ns"},
  592. 15 => {name => "luminance_intensity", unit => "lux"},
  593. 16 => {name => "magnetic_field_strength", unit => "A/m"},
  594. 17 => {name => "mass", unit => "kg"},
  595. 18 => {name => "mass_density", unit => "kg/m2"},
  596. 19 => {name => "mass_flow", unit => "kg/s"},
  597. 20 => {name => "power", unit => "W"},
  598. 21 => {name => "pressure", unit => "Pa"},
  599. 22 => {name => "relative_humidity", unit => "%"},
  600. 23 => {name => "resistance", unit => "Ohm"},
  601. 24 => {name => "temperature", unit => "C"},
  602. 25 => {name => "time", unit => "s"},
  603. 26 => {name => "torque", unit => "Nm"},
  604. 27 => {name => "velocity", unit => "m/s"},
  605. 28 => {name => "voltage", unit => "V"},
  606. 29 => {name => "volume", unit => "m3"},
  607. 30 => {name => "volumetric_flow", unit => "m3/s"},
  608. );
  609. # Initialize
  610. sub
  611. EnOcean_Initialize($)
  612. {
  613. my ($hash) = @_;
  614. my %subTypeList;
  615. my @subTypeList;
  616. foreach my $eep (keys %EnO_eepConfig){
  617. push @subTypeList, $EnO_eepConfig{$eep}{attr}{subType};
  618. }
  619. my $subTypeList = join(",", sort grep { !$subTypeList{$_}++ } @subTypeList);
  620. $hash->{AutoCreate} = {"EnO.*" => {ATTR => "creator:autocreate", FILTER => "%NAME"}};
  621. $hash->{noAutocreatedFilelog} = 1;
  622. $hash->{Match} = "^EnOcean:";
  623. $hash->{DefFn} = "EnOcean_Define";
  624. $hash->{DeleteFn} = "EnOcean_Delete";
  625. $hash->{UndefFn} = "EnOcean_Undef";
  626. $hash->{ParseFn} = "EnOcean_Parse";
  627. $hash->{SetFn} = "EnOcean_Set";
  628. #$hash->{StateFn} = "EnOcean_State";
  629. $hash->{GetFn} = "EnOcean_Get";
  630. $hash->{NotifyFn} = "EnOcean_Notify";
  631. $hash->{AttrFn} = "EnOcean_Attr";
  632. $hash->{AttrList} = "IODev do_not_notify:1,0 ignore:0,1 dummy:0,1 " .
  633. "showtime:1,0 " .
  634. "actualTemp angleMax:slider,-180,20,180 alarmAction " .
  635. "angleMin:slider,-180,20,180 " .
  636. "angleTime setCmdTrigger:man,refDev blockUnknownMSC:no,yes blockMotion:no,yes " .
  637. "blockTemp:no,yes blockDisplay:no,yes blockDateTime:no,yes " .
  638. "blockTimeProgram:no,yes blockOccupancy:no,yes blockSetpointTemp:no,yes " .
  639. "blockFanSpeed:no,yes blockKey:no,yes comMode:confirm,biDir,uniDir creator:autocreate,manual " .
  640. "daylightSavingTime:supported,not_supported dataEnc:VAES,AES-CBC " .
  641. "defaultChannel:" . join(",", @EnO_defaultChannel) . " " .
  642. "demandRespAction demandRespRefDev demandRespMax:A0,AI,B0,BI,C0,CI,D0,DI ".
  643. "demandRespMin:A0,AI,B0,BI,C0,CI,D0,DI demandRespRandomTime " .
  644. "demandRespThreshold:slider,0,1,15 demandRespTimeoutLevel:max,last destinationID " .
  645. "devChannel devMode:master,slave devUpdate:off,auto,demand,polling,interrupt " .
  646. "dimMax dimMin dimValueOn disable:0,1 disabledForIntervals " .
  647. "displayContent:default,humidity,off,setpointTemp,tempertureExtern,temperatureIntern,time,no_change " .
  648. "displayOrientation:0,90,180,270 " .
  649. "eep gpDef gwCmd:" . join(",", sort @EnO_gwCmd) . " humitity humidityRefDev " .
  650. "keyRcv keySnd macAlgo:no,3,4 measurementCtrl:disable,enable " .
  651. "manufID:" . join(",", sort keys %EnO_manuf) . " " .
  652. "model:" . join(",", @EnO_models) . " " .
  653. "observe:on,off observeCmdRepetition:1,2,3,4,5 observeErrorAction observeInterval observeLogic:and,or " .
  654. #observeCmds observeExeptions
  655. "observeRefDev pidActorErrorAction:errorPos,freeze pidActorCallBeforeSetting pidActorErrorPos " .
  656. "pidActorLimitLower pidActorLimitUpper pidCtrl:on,off pidDeltaTreshold pidFactor_D pidFactor_I " .
  657. "pidFactor_P pidIPortionCallBeforeSetting pidSensorTimeout " .
  658. "pollInterval postmasterID productID rampTime rcvRespAction ".
  659. "releasedChannel:A,B,C,D,I,0,auto repeatingAllowed:yes,no remoteCode remoteEEP remoteID remoteManufID " .
  660. "remoteManagement:client,manager,off rlcAlgo:no,2++,3++ rlcRcv rlcSnd rlcTX:true,false " .
  661. "reposition:directly,opens,closes rltRepeat:16,32,64,128,256 rltType:1BS,4BS " .
  662. "scaleDecimals:0,1,2,3,4,5,6,7,8,9 scaleMax scaleMin secMode:rcv,snd,bidir " .
  663. "secLevel:encapsulation,encryption,off sendDevStatus:no,yes sensorMode:switch,pushbutton " .
  664. "serviceOn:no,yes settingAccuracy:high,low setpointRefDev setpointSummerMode:slider,0,5,100 " .
  665. "setpointTempRefDev shutTime shutTimeCloses subDef " .
  666. "subDef0 subDefI subDefA subDefB subDefC subDefD subDefH subDefW " .
  667. "subType:$subTypeList subTypeSet:$subTypeList subTypeReading:$subTypeList " .
  668. "summerMode:off,on switchMode:switch,pushbutton " .
  669. "switchHysteresis switchType:direction,universal,channel,central " .
  670. "teachMethod:1BS,4BS,confirm,GP,RPS,smartAck,STE,UTE temperatureRefDev " .
  671. "temperatureScale:C,F,default,no_change timeNotation:12,24,default,no_change " .
  672. "timeProgram1 timeProgram2 timeProgram3 timeProgram4 trackerWakeUpCycle:10,20,30,40,60,120,180,240,3600,86400 updateState:default,yes,no " .
  673. "uteResponseRequest:yes,no " .
  674. "wakeUpCycle:" . join(",", keys %wakeUpCycle) . " " .
  675. $readingFnAttributes;
  676. for (my $i = 0; $i < @EnO_ptm200btn; $i++) {
  677. $EnO_ptm200btn{$EnO_ptm200btn[$i]} = "$i:30";
  678. }
  679. $EnO_ptm200btn{released} = "0:20";
  680. if ($cryptFunc == 1){
  681. Log3 undef, 2, "EnOcean Cryptographic functions available.";
  682. } else {
  683. Log3 undef, 2, "EnOcean Cryptographic functions are not available.";
  684. }
  685. return undef;
  686. }
  687. # Define
  688. sub EnOcean_Define($$) {
  689. my ($hash, $def) = @_;
  690. my @a = split("[ \t][ \t]*", $def);
  691. my $name = $hash->{NAME};
  692. my ($autocreateFilelog, $autocreateHash, $autocreateName, $autocreateDeviceRoom, $autocreateWeblinkRoom) =
  693. ('./log/' . $name . '-%Y.log', undef, 'autocreate', 'EnOcean', 'Plots');
  694. my ($cmd, $eep, $ret);
  695. my $filelogName = "FileLog_$name";
  696. $def = "00000000";
  697. if(@a > 2 && @a < 5) {
  698. # find autocreate device
  699. while (($autocreateName, $autocreateHash) = each(%defs)) {
  700. last if ($defs{$autocreateName}{TYPE} eq "autocreate");
  701. }
  702. $autocreateDeviceRoom = AttrVal($autocreateName, "device_room", $autocreateDeviceRoom);
  703. $autocreateDeviceRoom = 'EnOcean' if ($autocreateDeviceRoom eq '%TYPE');
  704. $autocreateDeviceRoom = $name if ($autocreateDeviceRoom eq '%NAME');
  705. $autocreateDeviceRoom = AttrVal($name, "room", $autocreateDeviceRoom);
  706. if ($init_done) {
  707. Log3 $name, 2, "EnOcean define " . join(' ', @a);
  708. if (!defined(AttrVal($autocreateName, "disable", undef)) && !exists($defs{$filelogName})) {
  709. # create FileLog
  710. $autocreateFilelog = $attr{$autocreateName}{filelog} if (exists $attr{$autocreateName}{filelog});
  711. $autocreateFilelog =~ s/%NAME/$name/g;
  712. $cmd = "$filelogName FileLog $autocreateFilelog $name";
  713. Log3 $filelogName, 2, "EnOcean define $cmd";
  714. $ret = CommandDefine(undef, $cmd);
  715. if($ret) {
  716. Log3 $filelogName, 2, "EnOcean ERROR: $ret";
  717. } else {
  718. $attr{$filelogName}{room} = $autocreateDeviceRoom;
  719. $attr{$filelogName}{logtype} = 'text';
  720. }
  721. }
  722. }
  723. if ($a[2] eq "getNextID") {
  724. AssignIoPort($hash) if (!exists $hash->{IODev});
  725. if (exists $hash->{OLDDEF}) {
  726. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  727. }
  728. $hash->{DEF} = $def;
  729. $def = EnOcean_CheckSenderID("getNextID", $hash->{IODev}{NAME}, "00000000");
  730. $hash->{DEF} = $def;
  731. $modules{EnOcean}{defptr}{$def} = $hash;
  732. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  733. $attr{$name}{room} = $autocreateDeviceRoom;
  734. $attr{$name}{subType} = "raw" if (!exists $attr{$name}{subType});
  735. } elsif ($a[2] =~ m/^[A-Fa-f0-9]{8}$/i) {
  736. # DestinationID
  737. $def = uc($a[2]);
  738. $hash->{DEF} = $def;
  739. if (defined($a[3]) && $a[3] =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  740. # EEP
  741. my ($rorg, $func, $type) = (uc($1), uc($2), uc($3));
  742. $rorg = "F6" if ($rorg eq "05");
  743. $rorg = "D5" if ($rorg eq "06");
  744. $rorg = "A5" if ($rorg eq "07");
  745. $eep = "$rorg.$func.$type";
  746. if (exists $EnO_eepConfig{$eep}) {
  747. if ($eep eq 'A5.3F.00') {
  748. my ($rltHash, $rltName);
  749. foreach my $dev (keys %defs) {
  750. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  751. next if (!exists($attr{$dev}{subType}));
  752. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  753. $rltHash = $defs{$dev};
  754. $rltName = $rltHash->{NAME};
  755. last;
  756. }
  757. return "Radio Link Test device already defined, use $rltName" if ($rltHash);
  758. }
  759. AssignIoPort($hash) if (!exists $hash->{IODev});
  760. if (exists $hash->{OLDDEF}) {
  761. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  762. }
  763. $modules{EnOcean}{defptr}{$def} = $hash;
  764. if (exists($attr{$name}{eep}) && $attr{$name}{eep} ne "$rorg-$func-$type") {
  765. delete $attr{$name};
  766. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . 'text'
  767. if (exists $attr{$filelogName}{logtype});
  768. # delete SVG devices
  769. my ($weblinkName, $weblinkHash);
  770. while (($weblinkName, $weblinkHash) = each(%defs)) {
  771. if ($weblinkName =~ /^SVG_$name.*/) {
  772. CommandDelete(undef, $weblinkName);
  773. Log3 $hash->{NAME}, 2, "EnOcean $weblinkName deleted";
  774. }
  775. }
  776. }
  777. $attr{$name}{eep} = "$rorg-$func-$type";
  778. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  779. $attr{$name}{room} = $autocreateDeviceRoom;
  780. foreach my $attrCntr (keys %{$EnO_eepConfig{$eep}{attr}}) {
  781. if ($attrCntr eq "subDef") {
  782. if (!exists $attr{$name}{$attrCntr}) {
  783. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_eepConfig{$eep}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  784. }
  785. } else {
  786. $attr{$name}{$attrCntr} = $EnO_eepConfig{$eep}{attr}{$attrCntr};
  787. }
  788. }
  789. EnOcean_CreateSVG(undef, $hash, $a[3]);
  790. } else {
  791. return "EEP $rorg-$func-$type not supported";
  792. }
  793. } elsif (defined($a[3]) && $a[3] =~ m/^EnOcean:.*/) {
  794. # autocreate: parse received device telegram
  795. AssignIoPort($hash) if (!exists $hash->{IODev});
  796. $modules{EnOcean}{defptr}{$def} = $hash;
  797. my @msg = split(':', $a[3]);
  798. my $packetType = hex $msg[1];
  799. if ($packetType == 1) {
  800. my ($data, $rorg, $status);
  801. #EnOcean:PacketType:RORG:MessageData:SourceID:Status:OptionalData
  802. (undef, undef, $rorg, $data, undef, $status, undef) = @msg;
  803. $attr{$name}{subType} = $EnO_rorgname{$rorg};
  804. if ($attr{$name}{subType} eq "switch") {
  805. my $nu = (hex($status) & 0x10) >> 4;
  806. my $t21 = (hex($status) & 0x20) >> 5;
  807. $attr{$name}{manufID} = "7FF";
  808. if ($t21 && $nu) {
  809. $attr{$name}{eep} = "F6-02-01";
  810. readingsSingleUpdate($hash, "teach", "RPS teach-in accepted EEP F6-02-01 Manufacturer: no ID", 1);
  811. $attr{$name}{teachMethod} = 'RPS';
  812. Log3 $name, 2, "EnOcean $name teach-in EEP F6-02-01 Manufacturer: no ID";
  813. } elsif (!$t21 && $nu) {
  814. $attr{$name}{eep} = "F6-03-01";
  815. readingsSingleUpdate($hash, "teach", "RPS teach-in accepted EEP F6-03-01 Manufacturer: no ID", 1);
  816. $attr{$name}{teachMethod} = 'RPS';
  817. Log3 $name, 2, "EnOcean $name teach-in EEP F6-03-01 Manufacturer: no ID";
  818. } elsif ($t21 && !$nu) {
  819. $attr{$name}{subType} = "windowHandle";
  820. $attr{$name}{eep} = "F6-10-00";
  821. readingsSingleUpdate($hash, "teach", "RPS teach-in accepted EEP F6-10-00 Manufacturer: no ID", 1);
  822. $attr{$name}{teachMethod} = 'RPS';
  823. Log3 $name, 2, "EnOcean $name teach-in EEP F6-10-00 Manufacturer: no ID";
  824. }
  825. } elsif ($attr{$name}{subType} eq "contact" && hex($data) & 8) {
  826. $attr{$name}{eep} = "D5-00-01";
  827. $attr{$name}{manufID} = "7FF";
  828. readingsSingleUpdate($hash, "teach", "1BS teach-in accepted EEP D5-00-01 Manufacturer: no ID", 1);
  829. $attr{$name}{teachMethod} = '1BS';
  830. Log3 $name, 2, "EnOcean $name teach-in EEP D5-00-01 Manufacturer: no ID";
  831. } elsif ($attr{$name}{subType} eq "4BS" && hex(substr($data, 6, 2)) & 8) {
  832. $hash->{helper}{teachInWait} = "4BS";
  833. readingsSingleUpdate($hash, "teach", "4BS teach-in is missing", 1);
  834. Log3 $name, 2, "EnOcean $name 4BS teach-in is missing";
  835. } elsif ($attr{$name}{subType} eq "UTE") {
  836. $hash->{helper}{teachInWait} = "UTE";
  837. } elsif ($attr{$name}{subType} eq "VLD") {
  838. $hash->{helper}{teachInWait} = "UTE";
  839. readingsSingleUpdate($hash, "teach", "UTE teach-in is missing", 1);
  840. Log3 $name, 2, "EnOcean $name UTE teach-in is missing";
  841. } elsif ($attr{$name}{subType} eq "MSC") {
  842. readingsSingleUpdate($hash, "teach", "MSC not supported", 1);
  843. Log3 $name, 2, "EnOcean $name MSC not supported";
  844. } elsif ($attr{$name}{subType} =~ m/^SEC|ENC$/) {
  845. $hash->{helper}{teachInWait} = "STE";
  846. readingsSingleUpdate($hash, "teach", "STE teach-in is missing", 1);
  847. Log3 $name, 2, "EnOcean $name STE teach-in is missing";
  848. } elsif ($attr{$name}{subType} =~ m/^GPCD|GPSD$/) {
  849. $hash->{helper}{teachInWait} = "GPTI";
  850. readingsSingleUpdate($hash, "teach", "GP teach-in is missing", 1);
  851. Log3 $name, 2, "EnOcean $name GP teach-in is missing";
  852. }
  853. } elsif ($packetType == 4) {
  854. $hash->{helper}{smartAckLearnWait} = $name;
  855. } elsif ($packetType == 7) {
  856. # remote management
  857. #EnOcean:PacketType:RORG:MessageData:SourceID:DestinationID:FunctionNumber:ManufacturerID:RSSI:Delay
  858. if (hex($msg[6]) < 0x600) {
  859. $attr{$name}{remoteManagement} = 'client';
  860. # unlock device to send acknowledgment telegram
  861. $hash->{RemoteClientUnlock} = 1;
  862. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  863. RemoveInternalTimer(\%functionHash);
  864. InternalTimer(gettimeofday() + 1, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  865. } else {
  866. $attr{$name}{remoteManagement} = 'manager';
  867. }
  868. $attr{$name}{eep} = 'C5-00-00';
  869. $attr{$name}{manufID} = substr($msg[7], 1);
  870. $attr{$name}{remoteEEP} = 'C5-00-00';
  871. $attr{$name}{remoteID} = $msg[4];
  872. $attr{$name}{remoteManufID} = substr($msg[7], 1);
  873. $attr{$name}{subType} = 'remote';
  874. $modules{EnOcean}{defptr}{$msg[4]} = $hash;
  875. }
  876. EnOcean_Parse($hash, $a[3]);
  877. if (exists $attr{$name}{eep}) {
  878. $attr{$name}{eep} =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i;
  879. $eep = uc("$1.$2.$3");
  880. if (exists($attr{$filelogName}{logtype}) && exists($EnO_eepConfig{$eep}{GPLOT})) {
  881. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . 'text';
  882. EnOcean_CreateSVG(undef, $hash, undef);
  883. }
  884. }
  885. } else {
  886. # no device infos
  887. AssignIoPort($hash) if (!exists $hash->{IODev});
  888. # assign defptr
  889. if (exists $hash->{OLDDEF}) {
  890. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  891. }
  892. $modules{EnOcean}{defptr}{$def} = $hash;
  893. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  894. $attr{$name}{room} = $autocreateDeviceRoom;
  895. $attr{$name}{subType} = "raw" if (!exists $attr{$name}{subType});
  896. }
  897. } elsif ($a[2] =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  898. # EEP
  899. my ($rorg, $func, $type) = (uc($1), uc($2), uc($3));
  900. $rorg = "F6" if ($rorg eq "05");
  901. $rorg = "D5" if ($rorg eq "06");
  902. $rorg = "A5" if ($rorg eq "07");
  903. $eep = "$rorg.$func.$type";
  904. if (exists $EnO_eepConfig{$eep}) {
  905. if ($eep eq 'A5.3F.00') {
  906. # radio link test device
  907. my ($rltHash, $rltName);
  908. foreach my $dev (keys %defs) {
  909. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  910. next if (!exists($attr{$dev}{subType}));
  911. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  912. $rltHash = $defs{$dev};
  913. $rltName = $rltHash->{NAME};
  914. last;
  915. }
  916. return "Radio Link Test device already defined, use $rltName" if ($rltHash);
  917. }
  918. AssignIoPort($hash) if (!exists $hash->{IODev});
  919. if (exists($hash->{OLDDEF}) && $hash->{OLDDEF} =~ m/^[A-Fa-f0-9]{8}$/i) {
  920. delete $modules{EnOcean}{defptr}{$hash->{OLDDEF}};
  921. if ($hash->{DEF} =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  922. $def = $hash->{OLDDEF};
  923. $hash->{DEF} = $hash->{OLDDEF};
  924. }
  925. } else {
  926. $hash->{DEF} = $def;
  927. if ($eep eq 'A5.3F.00') {
  928. $attr{$name}{subDef} = EnOcean_CheckSenderID("getNextID", $hash->{IODev}{NAME}, "00000000");
  929. } elsif ($eep eq 'C5.00.00') {
  930. # remote management
  931. } else {
  932. $def = EnOcean_CheckSenderID("getNextID", $hash->{IODev}{NAME}, "00000000");
  933. $hash->{DEF} = $def;
  934. }
  935. }
  936. $modules{EnOcean}{defptr}{$def} = $hash;
  937. if (exists($attr{$name}{eep}) && $attr{$name}{eep} ne "$rorg-$func-$type") {
  938. delete $attr{$name};
  939. if (exists $attr{$filelogName}{logtype}) {
  940. if (exists$EnO_eepConfig{$eep}{GPLOT}) {
  941. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . 'text';
  942. } else {
  943. $attr{$filelogName}{logtype} = 'text';
  944. }
  945. }
  946. }
  947. $attr{$name}{eep} = "$rorg-$func-$type";
  948. $attr{$name}{manufID} = "7FF" if (!exists $attr{$name}{manufID});
  949. $attr{$name}{room} = $autocreateDeviceRoom;
  950. foreach my $attrCntr (keys %{$EnO_eepConfig{$eep}{attr}}) {
  951. if ($attrCntr ne "subDef") {
  952. $attr{$name}{$attrCntr} = $EnO_eepConfig{$eep}{attr}{$attrCntr};
  953. }
  954. }
  955. EnOcean_CreateSVG('del', $hash, $a[2]);
  956. } else {
  957. return "EEP $rorg-$func-$type not supported";
  958. }
  959. } else {
  960. return "wrong syntax: define <name> EnOcean <8-digit-hex-code> [<EEP>]|getNextID|<EEP>";
  961. }
  962. } else {
  963. return "wrong syntax: define <name> EnOcean <8-digit-hex-code> [<EEP>]|getNextID|<EEP>";
  964. }
  965. # device specific actions
  966. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  967. # pid parameter
  968. @{$hash->{helper}{calcPID}} = (undef, $hash, 'defined');
  969. $hash->{helper}{stopped} = 0;
  970. #$hash->{helper}{adjust} = '';
  971. }
  972. # all notifys needed
  973. #$hash->{NOTIFYDEV} = "global";
  974. Log3 $name, 5, "EnOcean_define for device $name executed.";
  975. return undef;
  976. }
  977. # Get
  978. sub EnOcean_Get($@)
  979. {
  980. my ($hash, @a) = @_;
  981. return "no get value specified" if (@a < 2);
  982. my $name = $hash->{NAME};
  983. if (IsDisabled($name)) {
  984. Log3 $name, 4, "EnOcean $name get commands disabled.";
  985. return;
  986. }
  987. my $cmdID;
  988. my $cmdList = "";
  989. my $data;
  990. my $destinationID = AttrVal($name, "destinationID", undef);
  991. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  992. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  993. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  994. } elsif (!defined $destinationID || $destinationID eq "multicast") {
  995. $destinationID = "FFFFFFFF";
  996. } elsif ($destinationID eq "unicast") {
  997. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  998. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  999. } elsif ($destinationID !~ m/^[\dA-Fa-f]{8}$/) {
  1000. return "DestinationID $destinationID wrong, choose <8-digit-hex-code>.";
  1001. }
  1002. $destinationID = uc($destinationID);
  1003. my $eep = uc(AttrVal($name, "eep", "00-00-00"));
  1004. if ($eep =~ m/^([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})$/i) {
  1005. $eep = (((hex($1) << 6) | hex($2)) << 7) | hex($3);
  1006. } else {
  1007. $eep = (((hex("FF") << 6) | hex("3F")) << 7) | hex("7F");
  1008. }
  1009. my $manufID = uc(AttrVal($name, "manufID", ""));
  1010. my $model = AttrVal($name, "model", "");
  1011. my $packetType = 1;
  1012. $packetType = 0x0A if (ReadingsVal($hash->{IODev}{NAME}, "mode", "00") eq "01");
  1013. my $remoteID = AttrVal($name, "remoteID", undef);
  1014. my $remoteManufID = uc(AttrVal($name, "remoteManufID", AttrVal($name, "manufID", "")));
  1015. my $rorg;
  1016. my $status = '00';
  1017. my $st = AttrVal($name, "subType", "");
  1018. my $stSet = AttrVal($name, "subTypeSet", undef);
  1019. if (defined $stSet) {$st = $stSet;}
  1020. my $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  1021. if ($subDef !~ m/^[\dA-F]{8}$/) {return "SenderID $subDef wrong, choose <8-digit-hex-code>.";}
  1022. my $timeNow = TimeNow();
  1023. if (AttrVal($name, "remoteManagement", "off") eq "manager") {
  1024. # Remote Management
  1025. $cmdList = "remoteDevCfg remoteFunctions:noArg remoteID:noArg remoteLinkCfg remoteLinkTableInfo:noArg remoteLinkTable remoteLinkTableGP remotePing:noArg remoteProductID:noArg remoteRepeater:noArg remoteStatus:noArg ";
  1026. }
  1027. # control get actions
  1028. # $updateState = -1: no get commands available e. g. sensors
  1029. # 0: execute get commands
  1030. # 1: execute get commands and and update reading state
  1031. # 2: execute get commands delayed
  1032. my $updateState = 1;
  1033. #Log3 $name, 5, "EnOcean $name EnOcean_Get command: " . join(" ", @a);
  1034. shift @a;
  1035. for (my $i = 0; $i < @a; $i++) {
  1036. my $cmd = $a[$i];
  1037. if ($cmd eq "remoteID") {
  1038. $cmdID = 4;
  1039. $manufID = 0x7FF;
  1040. $packetType = 7;
  1041. $rorg = "C5";
  1042. shift(@a);
  1043. $data = sprintf "0004%04X%06X", $manufID, ($eep << 3);
  1044. $destinationID = "FFFFFFFF";
  1045. $status = '0F';
  1046. $hash->{IODev}{helper}{remoteAnswerWait}{0x604}{hash} = $hash;
  1047. my %functionHash = (hash => $hash, param => 0x604);
  1048. RemoveInternalTimer(\%functionHash);
  1049. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1050. Log3 $name, 3, "EnOcean get $name $cmd";
  1051. } elsif ($cmd eq "remotePing") {
  1052. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1053. $cmdID = 6;
  1054. $manufID = 0x7FF;
  1055. $packetType = 7;
  1056. $rorg = "C5";
  1057. shift(@a);
  1058. $data = sprintf "0006%04X", $manufID;
  1059. $destinationID = $remoteID;
  1060. $status = '0F';
  1061. $hash->{IODev}{helper}{remoteAnswerWait}{0x606}{hash} = $hash;
  1062. my %functionHash = (hash => $hash, param => 0x606);
  1063. RemoveInternalTimer(\%functionHash);
  1064. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1065. Log3 $name, 3, "EnOcean get $name $cmd";
  1066. } elsif ($cmd eq "remoteFunctions") {
  1067. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1068. $cmdID = 7;
  1069. $manufID = 0x7FF;
  1070. $packetType = 7;
  1071. $rorg = "C5";
  1072. shift(@a);
  1073. $data = sprintf "0007%04X", $manufID;
  1074. $destinationID = $remoteID;
  1075. $status = '0F';
  1076. $hash->{IODev}{helper}{remoteAnswerWait}{0x607}{hash} = $hash;
  1077. my %functionHash = (hash => $hash, param => 0x607);
  1078. RemoveInternalTimer(\%functionHash);
  1079. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1080. Log3 $name, 3, "EnOcean get $name $cmd";
  1081. } elsif ($cmd eq "remoteStatus") {
  1082. $cmdID = 8;
  1083. $manufID = 0x7FF;
  1084. $packetType = 7;
  1085. $rorg = "C5";
  1086. shift(@a);
  1087. $data = sprintf "0008%04X", $manufID;
  1088. if (defined $remoteID) {
  1089. $destinationID = $remoteID;
  1090. } else {
  1091. $destinationID = 'F' x 8;
  1092. }
  1093. $status = '0F';
  1094. $hash->{IODev}{helper}{remoteAnswerWait}{0x608}{hash} = $hash;
  1095. my %functionHash = (hash => $hash, param => 0x608);
  1096. RemoveInternalTimer(\%functionHash);
  1097. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1098. Log3 $name, 3, "EnOcean get $name $cmd";
  1099. } elsif ($cmd eq "remoteLinkTableInfo") {
  1100. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1101. $cmdID = 0x210;
  1102. $manufID = 0x7FF;
  1103. $packetType = 7;
  1104. $rorg = "C5";
  1105. shift(@a);
  1106. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1107. $destinationID = $remoteID;
  1108. $status = '0F';
  1109. $hash->{IODev}{helper}{remoteAnswerWait}{0x810}{hash} = $hash;
  1110. my %functionHash = (hash => $hash, param => 0x810);
  1111. RemoveInternalTimer(\%functionHash);
  1112. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1113. Log3 $name, 3, "EnOcean get $name $cmd";
  1114. } elsif ($cmd eq "remoteLinkTable") {
  1115. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1116. $cmdID = 0x211;
  1117. $manufID = 0x7FF;
  1118. $packetType = 7;
  1119. $rorg = "C5";
  1120. my $startRef;
  1121. my $endRef;
  1122. my $direction;
  1123. 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}$/) {
  1124. shift(@a);
  1125. $direction = shift(@a);
  1126. $direction = $direction eq 'out' ? '80' : '00';
  1127. $startRef = uc(shift(@a));
  1128. $endRef = uc(shift(@a));
  1129. ($startRef, $endRef) = ($endRef, $startRef) if (hex($startRef) > hex($endRef));
  1130. } else {
  1131. return "Wrong parameter or direction/startRef/endRef not defined.";
  1132. }
  1133. $data = sprintf "%04X%04X%2s%2s%2s", $cmdID, $manufID, $direction, $startRef, $endRef;
  1134. $destinationID = $remoteID;
  1135. $status = '0F';
  1136. $hash->{IODev}{helper}{remoteAnswerWait}{0x811}{hash} = $hash;
  1137. my %functionHash = (hash => $hash, param => 0x811);
  1138. RemoveInternalTimer(\%functionHash);
  1139. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1140. Log3 $name, 3, "EnOcean get $name $cmd";
  1141. } elsif ($cmd eq "remoteLinkTableGP") {
  1142. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1143. $cmdID = 0x213;
  1144. $manufID = 0x7FF;
  1145. $packetType = 7;
  1146. $rorg = "C5";
  1147. my $direction;
  1148. my $index;
  1149. if (defined($a[1]) && defined($a[2]) && $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/) {
  1150. shift(@a);
  1151. $direction = shift(@a);
  1152. $direction = $direction eq 'out' ? '80' : '00';
  1153. $index = uc(shift(@a));
  1154. } else {
  1155. return "Wrong parameter or direction/index not defined.";
  1156. }
  1157. $data = sprintf "%04X%04X%2s%2s", $cmdID, $manufID, $direction, $index;
  1158. $destinationID = $remoteID;
  1159. $status = '0F';
  1160. $hash->{IODev}{helper}{remoteAnswerWait}{0x813}{hash} = $hash;
  1161. my %functionHash = (hash => $hash, param => 0x813);
  1162. RemoveInternalTimer(\%functionHash);
  1163. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1164. Log3 $name, 3, "EnOcean get $name $cmd";
  1165. } elsif ($cmd eq "remoteProductID") {
  1166. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1167. $cmdID = 0x227;
  1168. $manufID = 0x7FF;
  1169. $packetType = 7;
  1170. $rorg = "C5";
  1171. shift(@a);
  1172. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1173. $destinationID = $remoteID;
  1174. $status = '0F';
  1175. $hash->{IODev}{helper}{remoteAnswerWait}{0x827}{hash} = $hash;
  1176. my %functionHash = (hash => $hash, param => 0x827);
  1177. RemoveInternalTimer(\%functionHash);
  1178. InternalTimer(gettimeofday() + 5.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1179. Log3 $name, 3, "EnOcean get $name $cmd";
  1180. } elsif ($cmd eq "remoteDevCfg") {
  1181. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1182. $cmdID = 0x230;
  1183. $manufID = 0x7FF;
  1184. $packetType = 7;
  1185. $rorg = "C5";
  1186. my $startRef;
  1187. my $endRef;
  1188. my $paraLen = '00';
  1189. if (defined($a[1]) && defined($a[2]) && $a[1] =~ m/^[\dA-Fa-f]{4}$/ && $a[2] =~ m/^[\dA-Fa-f]{4}$/) {
  1190. shift(@a);
  1191. $startRef = uc(shift(@a));
  1192. $endRef = uc(shift(@a));
  1193. ($startRef, $endRef) = ($endRef, $startRef) if (hex($startRef) > hex($endRef));
  1194. if (defined($a[0]) && $a[0] =~ m/^[\dA-Fa-f]{2}$/) {
  1195. $paraLen = uc(shift(@a));
  1196. }
  1197. } else {
  1198. return "Wrong parameter or startRef/endRef not defined.";
  1199. }
  1200. $data = sprintf "%04X%04X%4s%4s%2s", $cmdID, $manufID, $startRef, $endRef, $paraLen;
  1201. $destinationID = $remoteID;
  1202. $status = '0F';
  1203. $hash->{IODev}{helper}{remoteAnswerWait}{0x830}{hash} = $hash;
  1204. my %functionHash = (hash => $hash, param => 0x830);
  1205. RemoveInternalTimer(\%functionHash);
  1206. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1207. Log3 $name, 3, "EnOcean get $name $cmd";
  1208. } elsif ($cmd eq "remoteLinkCfg") {
  1209. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1210. $cmdID = 0x232;
  1211. $manufID = 0x7FF;
  1212. $packetType = 7;
  1213. $rorg = "C5";
  1214. my $direction;
  1215. my $idx;
  1216. my $startRef;
  1217. my $endRef;
  1218. my $paraLen = '00';
  1219. if (defined($a[1]) && defined($a[2]) && defined($a[3]) && defined($a[4])
  1220. && $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}$/) {
  1221. shift(@a);
  1222. $direction = shift(@a);
  1223. $direction = $direction eq 'out' ? '80' : '00';
  1224. $idx = uc(shift(@a));
  1225. $startRef = uc(shift(@a));
  1226. $endRef = uc(shift(@a));
  1227. ($startRef, $endRef) = ($endRef, $startRef) if (hex($startRef) > hex($endRef));
  1228. if (defined($a[0]) && $a[0] =~ m/^[\dA-Fa-f]{2}$/) {
  1229. $paraLen = uc(shift(@a));
  1230. }
  1231. } else {
  1232. return "Wrong parameter or startRef/endRef not defined.";
  1233. }
  1234. $data = sprintf "%04X%04X%2s%2s%4s%4s%2s", $cmdID, $manufID, $direction, $idx, $startRef, $endRef, $paraLen;
  1235. $destinationID = $remoteID;
  1236. $status = '0F';
  1237. $hash->{IODev}{helper}{remoteAnswerWait}{0x832}{hash} = $hash;
  1238. my %functionHash = (hash => $hash, param => 0x832);
  1239. RemoveInternalTimer(\%functionHash);
  1240. InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1241. Log3 $name, 3, "EnOcean get $name $cmd";
  1242. } elsif ($cmd eq "remoteRepeater") {
  1243. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1244. $cmdID = 0x250;
  1245. $manufID = 0x7FF;
  1246. $packetType = 7;
  1247. $rorg = "C5";
  1248. shift(@a);
  1249. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1250. $destinationID = $remoteID;
  1251. $status = '0F';
  1252. $hash->{IODev}{helper}{remoteAnswerWait}{0x850}{hash} = $hash;
  1253. my %functionHash = (hash => $hash, param => 0x850);
  1254. RemoveInternalTimer(\%functionHash);
  1255. InternalTimer(gettimeofday() + 5.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  1256. Log3 $name, 3, "EnOcean get $name $cmd";
  1257. } elsif ($st eq "switch.05") {
  1258. # Dual Channel Switch Actuator
  1259. # (A5-11-05)
  1260. $rorg = "A5";
  1261. shift(@a);
  1262. $updateState = 0;
  1263. if ($cmd eq "state") {
  1264. # query state
  1265. Log3 $name, 3, "EnOcean get $name $cmd";
  1266. $data = "00000008";
  1267. } else {
  1268. $cmdList .= "state:noArg";
  1269. return "Unknown argument $cmd, choose one of $cmdList";
  1270. }
  1271. } elsif ($st eq "lightCtrl.01") {
  1272. # Central Command, Extended Lighting-Control
  1273. # (A5-38-09)
  1274. $rorg = "A5";
  1275. shift(@a);
  1276. $updateState = 0;
  1277. if ($cmd eq "state") {
  1278. # query state
  1279. Log3 $name, 3, "EnOcean get $name $cmd";
  1280. $data = "00000008";
  1281. } else {
  1282. $cmdList .= "state:noArg";
  1283. return "Unknown argument $cmd, choose one of $cmdList";
  1284. }
  1285. } elsif ($st eq "actuator.01") {
  1286. # Electronic switches and dimmers with Energy Measurement and Local Control
  1287. # (D2-01-00 - D2-01-12)
  1288. $rorg = "D2";
  1289. shift(@a);
  1290. my $channel;
  1291. if ($cmd !~ m/^roomCtrlMode$/) {
  1292. $channel = shift(@a);
  1293. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  1294. if (!defined $channel || $channel eq "all") {
  1295. $channel = 30;
  1296. } elsif ($channel eq "input" || $channel + 0 == 31) {
  1297. $channel = 31;
  1298. } elsif ($channel + 0 >= 30) {
  1299. $channel = 30;
  1300. } elsif ($channel + 0 >= 0 && $channel + 0 <= 29) {
  1301. } else {
  1302. return "$cmd <channel> wrong, choose 0...29|all|input.";
  1303. }
  1304. }
  1305. if ($cmd eq "state") {
  1306. $cmdID = 3;
  1307. Log3 $name, 3, "EnOcean get $name $cmd $channel";
  1308. $data = sprintf "%02X%02X", $cmdID, $channel;
  1309. } elsif ($cmd eq "measurement") {
  1310. $cmdID = 6;
  1311. my $query = shift(@a);
  1312. if (!defined $query) {
  1313. return "$cmd <channel> <query> wrong, choose 0...30|all|input energy|power.";
  1314. } elsif ($query eq "energy") {
  1315. $query = 0;
  1316. } elsif ($query eq "power") {
  1317. $query = 1;
  1318. } else {
  1319. return "$cmd <channel> <query> wrong, choose 0...30|all|input energy|power.";
  1320. }
  1321. Log3 $name, 3, "EnOcean get $name $cmd $channel $query";
  1322. $data = sprintf "%02X%02X", $cmdID, $query << 5 | $channel;
  1323. } elsif ($cmd eq "roomCtrlMode") {
  1324. Log3 $name, 3, "EnOcean get $name $cmd";
  1325. $data = '09';
  1326. } elsif ($cmd eq "settings") {
  1327. $cmdID = 10;
  1328. Log3 $name, 3, "EnOcean get $name $cmd $channel";
  1329. $data = sprintf "%02X%02X", $cmdID, $channel;
  1330. } elsif ($cmd eq "special") {
  1331. $rorg = "D1";
  1332. my $query = shift(@a);
  1333. if ($manufID eq "033") {
  1334. if (!defined $query) {
  1335. return "$cmd <channel> <query> wrong, choose health|load|voltage|serialNumber.";
  1336. } elsif ($query eq "health") {
  1337. $query = 7;
  1338. } elsif ($query eq "load") {
  1339. $query = 8;
  1340. } elsif ($query eq "voltage") {
  1341. $query = 9;
  1342. } elsif ($query eq "serialNumber") {
  1343. $query = 0x81;
  1344. } else {
  1345. return "$cmd <channel> <query> wrong, choose health|load|voltage|serialNumber.";
  1346. }
  1347. $data = sprintf "0331%02X", $query;
  1348. Log3 $name, 3, "EnOcean get $name $cmd $channel $query";
  1349. readingsSingleUpdate($hash, "getParam", $query, 0);
  1350. } elsif ($manufID eq "046") {
  1351. if (!defined $query) {
  1352. return "$cmd <channel> <query> wrong, choose reset|firmwareVersion|taughtInDevNum|taughtInDevID.";
  1353. } elsif ($query eq "reset") {
  1354. $query = 1;
  1355. $data = sprintf "0046%02X", $query;
  1356. } elsif ($query eq "firmwareVersion") {
  1357. $query = 2;
  1358. $data = sprintf "0046%02X", $query;
  1359. } elsif ($query eq "taughtInDevNum") {
  1360. $query = 4;
  1361. $data = sprintf "0046%02X", $query;
  1362. } elsif ($query eq "taughtInDevID") {
  1363. $query = 6;
  1364. my $taughtInDevNum = shift(@a);
  1365. if (defined $taughtInDevNum && $taughtInDevNum =~ m/^\d+$/ && $taughtInDevNum >= 0 && $taughtInDevNum <= 23) {
  1366. $data = sprintf "0046%02X%02X", $query, $taughtInDevNum;
  1367. } else {
  1368. return "Usage: taughtInDevID is not numeric or out of range";
  1369. }
  1370. } else {
  1371. return "$cmd <channel> <query> wrong, choose reset|firmwareVersion|taughtInDevNum|taughtInDevID.";
  1372. }
  1373. Log3 $name, 3, "EnOcean get $name $cmd $channel $query";
  1374. readingsSingleUpdate($hash, "getParam", $query, 0);
  1375. }
  1376. } else {
  1377. if ($manufID =~ m/^033|046$/) {
  1378. return "Unknown argument $cmd, choose one of " . $cmdList . "state measurement roomCtrlMode:noArg special settings";
  1379. } else {
  1380. return "Unknown argument $cmd, choose one of " . $cmdList . "state measurement roomCtrlMode:noArg settings";
  1381. }
  1382. }
  1383. } elsif ($st =~ m/^blindsCtrl\.0[01]$/) {
  1384. # Blinds Control for Position and Angle
  1385. # (D2-05-xx)
  1386. $rorg = "D2";
  1387. shift(@a);
  1388. $updateState = 0;
  1389. if ($cmd eq "position") {
  1390. # query position and angle
  1391. $cmdID = 3;
  1392. my $channel = shift(@a);
  1393. if (!defined $channel) {
  1394. $channel = AttrVal($name, "defaultChannel", 'all');
  1395. $channel = $channel eq "all" ? 15 : $channel - 1;
  1396. } elsif ($channel =~ m/^all$/) {
  1397. $channel = 15;
  1398. } elsif ($channel =~ m/^[1234]$/) {
  1399. $channel -= 1;
  1400. } else {
  1401. return "$cmd parameter wrong, choose one of 1|2|3|4|all";
  1402. }
  1403. Log3 $name, 3, "EnOcean get $name $cmd";
  1404. $data = sprintf "%02X", $channel << 4 | $cmdID;
  1405. } else {
  1406. $cmdList .= "position";
  1407. return "Unknown argument $cmd, choose one of $cmdList";
  1408. }
  1409. } elsif ($st eq "multisensor.01") {
  1410. #####
  1411. # Multisensor Windows Handle
  1412. # (D2-06-01)
  1413. $rorg = "D2";
  1414. shift(@a);
  1415. $updateState = 2;
  1416. my $waitingCmds = ReadingsVal($name, "waitingCmds", undef);
  1417. if (defined $waitingCmds) {
  1418. # check presence state
  1419. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? $waitingCmds & 0xDF | 32 : $waitingCmds & 0xDF;
  1420. } else {
  1421. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? 32 : 0;
  1422. }
  1423. if ($cmd eq "config") {
  1424. # query config
  1425. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 0x80, 0);
  1426. Log3 $name, 3, "EnOcean get $name $cmd";
  1427. } elsif ($cmd eq "log") {
  1428. # query log
  1429. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 0x40, 0);
  1430. Log3 $name, 3, "EnOcean get $name $cmd";
  1431. } else {
  1432. $cmdList .= "config:noArg log:noArg";
  1433. return "Unknown argument $cmd, choose one of $cmdList";
  1434. }
  1435. } elsif ($st eq "roomCtrlPanel.00") {
  1436. # Room Control Panel
  1437. # (D2-10-00 - D2-10-02)
  1438. $rorg = "D2";
  1439. shift(@a);
  1440. $updateState = 2;
  1441. if ($cmd eq "data") {
  1442. # data request
  1443. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 1, 0);
  1444. Log3 $name, 3, "EnOcean get $name $cmd";
  1445. } elsif ($cmd eq "config") {
  1446. # configuration request
  1447. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 32, 0);
  1448. Log3 $name, 3, "EnOcean get $name $cmd";
  1449. } elsif ($cmd eq "roomCtrl") {
  1450. # room control setup request
  1451. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 128, 0);
  1452. Log3 $name, 3, "EnOcean get $name $cmd";
  1453. } elsif ($cmd eq "timeProgram") {
  1454. # time program request
  1455. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 256, 0);
  1456. Log3 $name, 3, "EnOcean get $name $cmd";
  1457. } else {
  1458. $cmdList .= "data:noArg config:noArg roomCtrl:noArg timeProgram:noArg";
  1459. return "Unknown argument $cmd, choose one of $cmdList";
  1460. }
  1461. } elsif ($st eq "fanCtrl.00") {
  1462. # Fan Control
  1463. # (D2-20-00 - D2-20-02)
  1464. $rorg = "D2";
  1465. shift(@a);
  1466. $updateState = 0;
  1467. if ($cmd eq "state") {
  1468. # query position and angle
  1469. $data = "F6FFFFFF";
  1470. Log3 $name, 3, "EnOcean get $name $cmd DATA: $data";
  1471. } else {
  1472. $cmdList .= "state:noArg";
  1473. return "Unknown argument $cmd, choose one of $cmdList";
  1474. }
  1475. } elsif ($st eq "heatRecovery.00") {
  1476. # heat recovery ventilation
  1477. # (D2-50-00)
  1478. $rorg = "D2";
  1479. shift(@a);
  1480. $updateState = 0;
  1481. if ($cmd eq "basicState") {
  1482. # query switch state
  1483. $data = "00";
  1484. Log3 $name, 3, "EnOcean get $name $cmd";
  1485. } elsif ($cmd eq "extendedState") {
  1486. # query switch state
  1487. $data = "01";
  1488. Log3 $name, 3, "EnOcean get $name $cmd";
  1489. } else {
  1490. $cmdList .= "basicState:noArg extendedState:noArg";
  1491. return "Unknown argument $cmd, choose one of $cmdList";
  1492. }
  1493. } elsif ($st eq "valveCtrl.00" && AttrVal($name, "devMode", "master") eq "master") {
  1494. # Valve Control
  1495. # (D2-A0-01)
  1496. $rorg = "D2";
  1497. shift(@a);
  1498. $updateState = 0;
  1499. if ($cmd eq "state") {
  1500. # query switch state
  1501. $data = "00";
  1502. readingsSingleUpdate($hash, "state", $cmd, 1);
  1503. Log3 $name, 3, "EnOcean get $name $cmd";
  1504. } else {
  1505. $cmdList .= "state:noArg";
  1506. return "Unknown argument $cmd, choose one of $cmdList";
  1507. }
  1508. } elsif ($st eq "remote") {
  1509. return "Unknown argument $cmd, choose one of $cmdList";
  1510. } else {
  1511. # subtype does not support get commands
  1512. if (AttrVal($name, "remoteManagement", "off") eq "manager") {
  1513. return "Unknown argument $cmd, choose one of $cmdList";
  1514. } else {
  1515. return;
  1516. }
  1517. }
  1518. if($updateState != 2) {
  1519. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, $status, $destinationID);
  1520. }
  1521. }
  1522. }
  1523. # Set
  1524. sub EnOcean_Set($@)
  1525. {
  1526. my ($hash, @a) = @_;
  1527. return "no set value specified" if (@a < 2);
  1528. my $name = $hash->{NAME};
  1529. if (IsDisabled($name)) {
  1530. Log3 $name, 4, "EnOcean $name set commands disabled.";
  1531. return;
  1532. }
  1533. my $cmdID;
  1534. my $cmdList = "";
  1535. my @cmdObserve = @a;
  1536. my ($ctrl, $data, $err, $logLevel, $response);
  1537. my $destinationID = AttrVal($name, "destinationID", undef);
  1538. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  1539. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  1540. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  1541. } elsif (!defined $destinationID || $destinationID eq "multicast") {
  1542. $destinationID = "FFFFFFFF";
  1543. } elsif ($destinationID eq "unicast") {
  1544. $destinationID = defined(AttrVal($name, "subDef", undef)) ? $hash->{DEF} : "FFFFFFFF";
  1545. $destinationID = "FFFFFFFF" if (uc(AttrVal($name, "subDef", $hash->{DEF})) eq uc($hash->{DEF}));
  1546. } elsif ($destinationID !~ m/^[\dA-Fa-f]{8}$/) {
  1547. return "DestinationID $destinationID wrong, choose <8-digit-hex-code>.";
  1548. }
  1549. $destinationID = uc($destinationID);
  1550. my $IODev = $hash->{IODev}{NAME};
  1551. my $IOHash = $defs{$IODev};
  1552. my $manufID = uc(AttrVal($name, "manufID", ""));
  1553. my $model = AttrVal($name, "model", "");
  1554. my $packetType = 1;
  1555. $packetType = 0x0A if (ReadingsVal($IODev, "mode", "00") eq "01");
  1556. my $remoteID = AttrVal($name, "remoteID", undef);
  1557. my $remoteManufID = uc(AttrVal($name, "remoteManufID", AttrVal($name, "manufID", "")));
  1558. my $rorg;
  1559. my $sendCmd = 1;
  1560. my $status = "00";
  1561. my $st = AttrVal($name, "subType", "");
  1562. my $stSet = AttrVal($name, "subTypeSet", undef);
  1563. if (defined $stSet) {$st = $stSet;}
  1564. my $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  1565. if ($subDef !~ m/^[\dA-F]{8}$/) {return "SenderID $subDef wrong, choose <8-digit-hex-code>.";}
  1566. my $switchMode = AttrVal($name, "switchMode", "switch");
  1567. my $timeNow = TimeNow();
  1568. my $remoteManagement = AttrVal($name, "remoteManagement", "off");
  1569. if ($remoteManagement eq "manager") {
  1570. # Remote Management Manager
  1571. $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 ";
  1572. } elsif ($remoteManagement eq "client" || $st eq "remote") {
  1573. # Remote Management Client
  1574. $cmdList .= "remoteLock:noArg remoteUnlock ";
  1575. }
  1576. # control set actions
  1577. # $updateState = -1: no set commands available e. g. sensors
  1578. # 0: execute set commands
  1579. # 1: execute set commands and and update reading state
  1580. # 2: execute set commands delayed
  1581. # 3: internal command
  1582. my $updateState = AttrVal($name, "comMode", "uniDir") eq "uniDir" ? 1 : 0;
  1583. my $updateStateAttr = AttrVal($name, "updateState", "default");
  1584. shift @a;
  1585. for (my $i = 0; $i < @a; $i++) {
  1586. my $cmd = $a[$i];
  1587. my ($cmd1, $cmd2);
  1588. if ($cmd eq "remoteUnlock") {
  1589. if ($remoteManagement eq "manager") {
  1590. # manager
  1591. $cmdID = 1;
  1592. my $remoteCode = AttrVal($name, "remoteCode", undef);
  1593. return "Security Code not defined, set attr $name remoteCode <00000001 ... FFFFFFFE>!" if (!defined($remoteCode));
  1594. $manufID = 0x7FF;
  1595. $packetType = 7;
  1596. $rorg = "C5";
  1597. $data = sprintf "%04X%04X%s", $cmdID, $manufID, uc($remoteCode);
  1598. if (defined $remoteID) {
  1599. $destinationID = $remoteID;
  1600. } else {
  1601. $destinationID = 'F' x 8;
  1602. }
  1603. $updateState = 0;
  1604. } else {
  1605. # client
  1606. my $remoteUnlockPeriod = 1800;
  1607. if (defined $a[1]) {
  1608. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 1800) {
  1609. $remoteUnlockPeriod = $a[1];
  1610. shift(@a);
  1611. } else {
  1612. return "Usage: $a[1] is not numeric or out of range";
  1613. }
  1614. }
  1615. $hash->{RemoteClientUnlock} = 1;
  1616. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  1617. RemoveInternalTimer(\%functionHash);
  1618. InternalTimer(gettimeofday() + $remoteUnlockPeriod, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  1619. $updateState = 3;
  1620. }
  1621. Log3 $name, 3, "EnOcean set $name $cmd";
  1622. } elsif ($cmd eq "remoteLock") {
  1623. if ($remoteManagement eq "manager") {
  1624. # manager
  1625. $cmdID = 2;
  1626. my $remoteCode = AttrVal($name, "remoteCode", undef);
  1627. return "Security Code not defined, set attr $name remoteCode <00000001 ... FFFFFFFE>!" if (!defined($remoteCode));
  1628. $manufID = 0x7FF;
  1629. $packetType = 7;
  1630. $rorg = "C5";
  1631. $data = sprintf "%04X%04X%s", $cmdID, $manufID, uc($remoteCode);
  1632. if (defined $remoteID) {
  1633. $destinationID = $remoteID;
  1634. } else {
  1635. $destinationID = 'F' x 8;
  1636. }
  1637. $updateState = 0;
  1638. } else {
  1639. # client
  1640. delete $hash->{RemoteClientUnlock};
  1641. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  1642. RemoveInternalTimer(\%functionHash);
  1643. $updateState = 3;
  1644. }
  1645. Log3 $name, 3, "EnOcean set $name $cmd";
  1646. } elsif ($cmd eq "remoteSetCode") {
  1647. $cmdID = 3;
  1648. my $remoteCode = AttrVal($name, "remoteCode", undef);
  1649. return "Security Code not defined, set attr $name remoteCode <00000001 ... FFFFFFFE>!" if (!defined($remoteCode));
  1650. $manufID = 0x7FF;
  1651. $packetType = 7;
  1652. $rorg = "C5";
  1653. $data = sprintf "%04X%04X%s", $cmdID, $manufID, uc($remoteCode);
  1654. if (defined $remoteID) {
  1655. $destinationID = $remoteID;
  1656. } else {
  1657. $destinationID = 'F' x 8;
  1658. }
  1659. Log3 $name, 3, "EnOcean set $name $cmd";
  1660. $updateState = 0;
  1661. } elsif ($cmd eq "remoteAction") {
  1662. $cmdID = 5;
  1663. $manufID = 0x7FF;
  1664. $packetType = 7;
  1665. $rorg = "C5";
  1666. $data = sprintf "%04X%04X", $cmdID, $manufID;
  1667. if (defined $remoteID) {
  1668. $destinationID = $remoteID;
  1669. } else {
  1670. $destinationID = 'F' x 8;
  1671. }
  1672. Log3 $name, 3, "EnOcean set $name $cmd";
  1673. $updateState = 0;
  1674. } elsif ($cmd eq "remoteLinkTable") {
  1675. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1676. if (defined $a[1] && defined $a[2] && defined $a[3] && defined $a[4] && defined $a[5] &&
  1677. $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}$/) {
  1678. $cmdID = 0x212;
  1679. $manufID = 0x7FF;
  1680. $packetType = 7;
  1681. $rorg = "C5";
  1682. $a[4] =~ m/^(..)-(..)-(..)$/;
  1683. $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]);
  1684. splice(@a,0,5);
  1685. Log3 $name, 3, "EnOcean set $name $cmd";
  1686. $updateState = 0;
  1687. } else {
  1688. return "Usage: $cmd arguments needed or wrong.";
  1689. }
  1690. } elsif ($cmd eq "remoteLinkTableGP") {
  1691. # gpDef example: ch2:O:1:24:1:7:-40:1:40:1
  1692. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1693. if (defined $a[1] && defined $a[2] && defined $a[3] && $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/) {
  1694. $cmdID = 0x214;
  1695. $manufID = 0x7FF;
  1696. $packetType = 7;
  1697. $rorg = "C5";
  1698. my $direction = $a[1] eq 'out' ? '80' : '00';
  1699. my $gpDef;
  1700. my ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  1701. split(':', $a[3]);
  1702. if ($channelDir eq "O" && $a[1] eq 'out' || $channelDir eq "I" && $a[1] eq 'in') {
  1703. # add channel-, signal- and valuetype
  1704. $gpDef .= substr(unpack('B8', pack('C', $channelType)), 6) .
  1705. unpack('B8', pack('C', $signalType)) .
  1706. substr(unpack('B8', pack('C', $valueType)), 6);
  1707. if ($channelType == 1 || $channelType == 3) {
  1708. # data, enumeration: add resolution
  1709. $gpDef .= substr(unpack('B8', pack('C', $resolution)), 4);
  1710. }
  1711. if ($channelType == 1) {
  1712. # data: add engineering and scaling
  1713. $gpDef .= unpack('B8', pack('c', $engMin)) .
  1714. substr(unpack('B8', pack('C', $scalingMin)), 4) .
  1715. unpack('B8', pack('c', $engMax)) .
  1716. substr(unpack('B8', pack('C', $scalingMax)), 4);
  1717. }
  1718. } else {
  1719. return "Usage: Link Table GP Entry Direction wrong.";
  1720. }
  1721. if (length($gpDef) % 8) {
  1722. # fill with trailing zeroes to x bytes
  1723. $gpDef .= 0 x (8 - length($gpDef) % 8);
  1724. }
  1725. $data = sprintf "%04X%04X%s%s%s", $cmdID, $manufID, $a[1] eq 'out' ? '80' : '00', uc($a[2]), EnOcean_convBitToHex($gpDef);
  1726. splice(@a,0,3);
  1727. Log3 $name, 3, "EnOcean set $name $cmd";
  1728. $updateState = 0;
  1729. } else {
  1730. return "Usage: $cmd arguments needed or wrong.";
  1731. }
  1732. } elsif ($cmd eq "remoteLearnMode") {
  1733. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1734. if (defined $a[1]) {
  1735. $cmdID = 0x220;
  1736. $manufID = 0x7FF;
  1737. $packetType = 7;
  1738. $rorg = "C5";
  1739. $destinationID = $remoteID;
  1740. my $learnMode;
  1741. my $cmdVal = 0;
  1742. if ($a[1] eq 'in') {
  1743. $learnMode = '00';
  1744. shift(@a);
  1745. } elsif ($a[1] eq 'out') {
  1746. $learnMode = '40';
  1747. shift(@a);
  1748. } elsif ($a[1] eq 'off') {
  1749. $learnMode = '80';
  1750. shift(@a);
  1751. } else {
  1752. return "Usage: $cmd $a[1] argument unknown.";
  1753. }
  1754. if (defined $a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  1755. $cmdVal = $a[1];
  1756. shift(@a);
  1757. } else {
  1758. return "Usage: $cmd <learnMode> argument needed or wrong.";
  1759. }
  1760. $data = sprintf "%04X%04X%s%s", $cmdID, $manufID, $learnMode, $cmdVal;
  1761. Log3 $name, 3, "EnOcean set $name $cmd";
  1762. $updateState = 0;
  1763. }
  1764. } elsif ($cmd eq "remoteTeach") {
  1765. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1766. if (defined $a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  1767. $cmdID = 0x221;
  1768. $manufID = 0x7FF;
  1769. $packetType = 7;
  1770. $rorg = "C5";
  1771. $destinationID = $remoteID;
  1772. $data = sprintf "%04X%04X%s", $cmdID, $manufID, $a[1];
  1773. shift(@a);
  1774. Log3 $name, 3, "EnOcean set $name $cmd";
  1775. $updateState = 0;
  1776. if (!exists($hash->{IODev}{Teach})) {
  1777. # enable teach-in receiving for 3 sec
  1778. $hash->{IODev}{Teach} = 1;
  1779. my %functionHash = (hash => $IOHash, param => 'Teach');
  1780. RemoveInternalTimer(\%functionHash);
  1781. InternalTimer(gettimeofday() + 3, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  1782. }
  1783. } else {
  1784. return "Usage: $cmd argument needed or wrong.";
  1785. }
  1786. } elsif ($cmd eq "remoteReset") {
  1787. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1788. if (defined $a[1] && $a[1] =~ m/^devCfg|linkTableIn|linkTableOut|no_change$/) {
  1789. $cmdID = 0x224;
  1790. $manufID = 0x7FF;
  1791. $packetType = 7;
  1792. $rorg = "C5";
  1793. $destinationID = $remoteID;
  1794. my %changeCmd = ('devCfg' => '80', 'linkTableIn' => '40', 'linkTableOut' => '20', 'no_change' => '00');
  1795. $data = sprintf "%04X%04X%s", $cmdID, $manufID, $changeCmd{$a[1]};
  1796. shift(@a);
  1797. Log3 $name, 3, "EnOcean set $name $cmd";
  1798. $updateState = 0;
  1799. } else {
  1800. return "Usage: $cmd argument needed or wrong.";
  1801. }
  1802. } elsif ($cmd eq "remoteRLT") {
  1803. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1804. if (defined $a[1] && defined $a[2] && $a[1] =~ m/^off|on$/ && $a[2] =~ m/^[0-7][1-9A-Fa-f]$/) {
  1805. $cmdID = 0x225;
  1806. $manufID = 0x7FF;
  1807. $packetType = 7;
  1808. $rorg = "C5";
  1809. $destinationID = $remoteID;
  1810. my $rltMode = hex $a[2];
  1811. $rltMode |= 0x80 if ($a[1] eq 'on');
  1812. $data = sprintf "%04X%04X%02X", $cmdID, $manufID, $rltMode;
  1813. splice(@a,0,2);
  1814. Log3 $name, 3, "EnOcean set $name $cmd";
  1815. $updateState = 0;
  1816. }
  1817. } elsif ($cmd eq "remoteApplyChanges") {
  1818. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1819. if (defined $a[1] && $a[1] =~ m/^devCfg|linkTable|no_change$/) {
  1820. $cmdID = 0x226;
  1821. $manufID = 0x7FF;
  1822. $packetType = 7;
  1823. $rorg = "C5";
  1824. $destinationID = $remoteID;
  1825. my %changeCmd = ('devCfg' => '40', 'linkTable' => '80', 'no_change' => '00');
  1826. $data = sprintf "%04X%04X%s", $cmdID, $manufID, $changeCmd{$a[1]};
  1827. shift(@a);
  1828. Log3 $name, 3, "EnOcean set $name $cmd";
  1829. $updateState = 0;
  1830. } else {
  1831. return "Usage: $cmd argument needed or wrong.";
  1832. }
  1833. } elsif ($cmd eq "remoteDevCfg") {
  1834. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1835. 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) {
  1836. $cmdID = 0x231;
  1837. $manufID = 0x7FF;
  1838. $packetType = 7;
  1839. $rorg = "C5";
  1840. $destinationID = $remoteID;
  1841. $data = sprintf "%04X%04X%s%02X%s", $cmdID, $manufID, uc($a[1]), length($a[2]) / 2, uc($a[2]);
  1842. splice(@a,0,2);
  1843. Log3 $name, 3, "EnOcean set $name $cmd";
  1844. $updateState = 0;
  1845. } else {
  1846. return "Usage: $cmd arguments needed or wrong.";
  1847. }
  1848. } elsif ($cmd eq "remoteLinkCfg") {
  1849. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1850. if (defined $a[1] && defined $a[2] && defined $a[3] && defined $a[4] &&
  1851. $a[1] =~ m/^in|out$/ && $a[2] =~ m/^[\dA-Fa-f]{2}$/ && $a[3] =~ m/^[\dA-Fa-f]{4}$/ &&
  1852. $a[4] =~ m/^[\dA-Fa-f]{2}[\dA-Fa-f]*$/ && length($a[4]) % 2 == 0) {
  1853. $cmdID = 0x233;
  1854. $manufID = 0x7FF;
  1855. $packetType = 7;
  1856. $rorg = "C5";
  1857. my $direction = $a[1] eq 'out' ? '80' : '00';
  1858. $destinationID = $remoteID;
  1859. $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]);
  1860. splice(@a,0,4);
  1861. Log3 $name, 3, "EnOcean set $name $cmd";
  1862. $updateState = 0;
  1863. } else {
  1864. return "Usage: $cmd arguments needed or wrong.";
  1865. }
  1866. } elsif ($cmd eq "remoteRepeater") {
  1867. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1868. if (defined $a[1] && defined $a[2] && defined $a[3] &&
  1869. $a[1] =~ m/^on|off|filter$/ && $a[2] =~ m/^[1-2]$/ && $a[3] =~ m/^AND|OR$/) {
  1870. $cmdID = 0x251;
  1871. $manufID = 0x7FF;
  1872. $packetType = 7;
  1873. $rorg = "C5";
  1874. my %repFunc = ('on' => 0x40, 'off' => 0, 'filter' => 0x80);
  1875. my $cmdVal = $repFunc{$a[1]} | ($a[2] == 2 ? 0x20 : 0x10) | ($a[3] eq 'OR' ? 8 : 0);
  1876. $destinationID = $remoteID;
  1877. $data = sprintf "%04X%04X%02X", $cmdID, $manufID, $cmdVal;
  1878. splice(@a,0,3);
  1879. Log3 $name, 3, "EnOcean set $name $cmd";
  1880. $updateState = 0;
  1881. } else {
  1882. return "Usage: $cmd arguments needed or wrong.";
  1883. }
  1884. } elsif ($cmd eq "remoteRepeaterFilter") {
  1885. return "Attribute remoteID is missing, please define it." if (!defined $remoteID);
  1886. if (defined $a[1] && defined $a[2] &&
  1887. $a[1] =~ m/^apply|block|delete|deleteAll$/ && $a[2] =~ m/^destinationID|sourceID|rorg|rssi$/) {
  1888. my %repFilterCtrl = ('deleteAll' => 0x30, 'delete' => 0x20, 'apply' => 0x10, 'block' => 0);
  1889. my $cmdVal = $repFilterCtrl{$a[1]};
  1890. my $cmdAttr;
  1891. if (defined $a[3]) {
  1892. if ($a[2] =~ m/^destinationID$/ && $a[3] =~ m/^[\dA-Fa-f]{8}$/) {
  1893. $cmdVal |= 3;
  1894. $cmdAttr = $a[3];
  1895. } elsif ($a[2] =~ m/^sourceID$/ && $a[3] =~ m/^[\dA-Fa-f]{8}$/) {
  1896. $cmdVal |= 0;
  1897. $cmdAttr = $a[3];
  1898. } elsif ($a[2] =~ m/^rorg$/ && $a[3] =~ m/^[\dA-Fa-f]{2}$/) {
  1899. $cmdVal |= 1;
  1900. $cmdAttr = '0' x 6 . $a[3];
  1901. } elsif ($a[2] =~ m/^rssi$/ && $a[3] =~ m/^-?\d+$/ && abs($a[3]) >= 0 && abs($a[3]) <= 255) {
  1902. $cmdVal |= 2;
  1903. $cmdAttr = sprintf "000000%02X", abs($a[3]);
  1904. } else {
  1905. return "Usage: $cmd $a[2] argument wrong.";
  1906. }
  1907. } else {
  1908. return "Usage: $cmd $a[2] argument needed.";
  1909. }
  1910. $cmdID = 0x252;
  1911. $manufID = 0x7FF;
  1912. $packetType = 7;
  1913. $rorg = "C5";
  1914. $destinationID = $remoteID;
  1915. $data = sprintf "%04X%04X%02X%s", $cmdID, $manufID, $cmdVal, $cmdAttr;
  1916. splice(@a,0,3);
  1917. Log3 $name, 3, "EnOcean set $name $cmd";
  1918. $updateState = 0;
  1919. } else {
  1920. return "Usage: $cmd arguments needed or wrong.";
  1921. }
  1922. } elsif ($st eq "switch") {
  1923. # Rocker Switch, simulate a PTM200 switch module
  1924. # separate first and second action
  1925. ($cmd1, $cmd2) = split(",", $cmd, 2);
  1926. # check values
  1927. if (!defined($EnO_ptm200btn{$cmd1}) || ($cmd2 && !defined($EnO_ptm200btn{$cmd2}))) {
  1928. $cmdList .= join(":noArg ", sort keys %EnO_ptm200btn) . ':noArg';
  1929. return SetExtensions($hash, $cmdList, $name, @a);
  1930. }
  1931. my $channelA = ReadingsVal($name, "channelA", undef);
  1932. my $channelB = ReadingsVal($name, "channelB", undef);
  1933. my $channelC = ReadingsVal($name, "channelC", undef);
  1934. my $channelD = ReadingsVal($name, "channelD", undef);
  1935. my $lastChannel = ReadingsVal($name, ".lastChannel", "A");
  1936. my $releasedChannel = AttrVal($name, "releasedChannel", "auto");
  1937. my $subDefA = AttrVal($name, "subDefA", $subDef);
  1938. my $subDefB = AttrVal($name, "subDefB", $subDef);
  1939. my $subDefC = AttrVal($name, "subDefC", $subDef);
  1940. my $subDefD = AttrVal($name, "subDefD", $subDef);
  1941. my $subDefI = AttrVal($name, "subDefI", $subDef);
  1942. my $subDef0 = AttrVal($name, "subDef0", $subDef);
  1943. my $switchType = AttrVal($name, "switchType", "direction");
  1944. # first action
  1945. if ($cmd1 eq "released") {
  1946. if ($switchType eq "central") {
  1947. if ($releasedChannel eq "auto") {
  1948. if ($lastChannel =~ m/0|I/) {
  1949. $releasedChannel = $lastChannel;
  1950. } else {
  1951. $releasedChannel = 0;
  1952. }
  1953. } elsif ($releasedChannel !~ m/0|I/) {
  1954. $releasedChannel = 0;
  1955. }
  1956. } elsif ($switchType eq "channel") {
  1957. if ($releasedChannel eq "auto") {
  1958. if ($lastChannel =~ m/A|B|C|D/) {
  1959. $releasedChannel = $lastChannel;
  1960. } else {
  1961. $releasedChannel = "A";
  1962. }
  1963. } elsif ($releasedChannel !~ m/A|B|C|D/) {
  1964. $releasedChannel = "A";
  1965. }
  1966. }
  1967. $subDef = AttrVal($name, "subDef" . $releasedChannel, $subDef);
  1968. } elsif ($switchType eq "central") {
  1969. if ($cmd1 =~ m/.0/) {
  1970. $subDef = $subDef0;
  1971. $lastChannel = 0;
  1972. } elsif ($cmd1 =~ m/.I/) {
  1973. $subDef = $subDefI;
  1974. $lastChannel = "I";
  1975. }
  1976. } elsif ($switchType eq "channel") {
  1977. $lastChannel = substr($cmd1, 0, 1);
  1978. $subDef = AttrVal($name, "subDef" . $lastChannel, $subDefA);
  1979. } else {
  1980. $lastChannel = substr($cmd1, 0, 1);
  1981. }
  1982. if ($switchType eq "universal") {
  1983. if ($cmd1 =~ m/A./ && (!defined($channelA) || $cmd1 ne $channelA)) {
  1984. $cmd1 = "A0";
  1985. } elsif ($cmd1 =~ m/B./ && (!defined($channelB) || $cmd1 ne $channelB)) {
  1986. $cmd1 = "B0";
  1987. } elsif ($cmd1 =~ m/C./ && (!defined($channelC) || $cmd1 ne $channelC)) {
  1988. $cmd1 = "C0";
  1989. } elsif ($cmd1 =~ m/D./ && (!defined($channelD) || $cmd1 ne $channelD)) {
  1990. $cmd1 = "D0";
  1991. } elsif ($cmd1 eq "released") {
  1992. } else {
  1993. $sendCmd = undef;
  1994. }
  1995. }
  1996. # second action
  1997. if ($cmd2 && $switchType eq "universal") {
  1998. if ($cmd2 =~ m/A./ && (!defined($channelA) || $cmd2 ne $channelA)) {
  1999. $cmd2 = "A0";
  2000. } elsif ($cmd2 =~ m/B./ && (!defined($channelB) || $cmd2 ne $channelB)) {
  2001. $cmd2 = "B0";
  2002. } elsif ($cmd2 =~ m/C./ && (!defined($channelC) || $cmd2 ne $channelC)) {
  2003. $cmd2 = "C0";
  2004. } elsif ($cmd2 =~ m/D./ && (!defined($channelD) || $cmd2 ne $channelD)) {
  2005. $cmd2 = "D0";
  2006. } else {
  2007. $cmd2 = undef;
  2008. }
  2009. if ($cmd2 && undef($sendCmd)) {
  2010. # only second action has changed, send as first action
  2011. $cmd1 = $cmd2;
  2012. $cmd2 = undef;
  2013. $sendCmd = 1;
  2014. }
  2015. }
  2016. # convert and send first and second command
  2017. my $switchCmd;
  2018. ($switchCmd, $status) = split(':', $EnO_ptm200btn{$cmd1}, 2);
  2019. # reset T21 status flag if 4 rocker
  2020. $status = '10' if ($switchCmd > 3);
  2021. $switchCmd <<= 5;
  2022. if ($cmd1 ne "released") {
  2023. # set the pressed flag
  2024. $switchCmd |= 0x10 ;
  2025. }
  2026. if($cmd2) {
  2027. # execute second action
  2028. if ($switchType =~ m/^central|channel$/) {
  2029. # second action not supported
  2030. $cmd = $cmd1;
  2031. } else {
  2032. my ($d2, undef) = split(':', $EnO_ptm200btn{$cmd2}, 2);
  2033. # reset T21 status flag if 4 rocker
  2034. $status = '10' if ($d2 > 3);
  2035. $switchCmd |= ($d2 << 1) | 0x01;
  2036. }
  2037. }
  2038. if (defined $sendCmd) {
  2039. $data = sprintf "%02X", $switchCmd;
  2040. $rorg = "F6";
  2041. #####
  2042. SetExtensionsCancel($hash);
  2043. Log3 $name, 3, "EnOcean set $name $cmd";
  2044. if ($updateState) {
  2045. readingsSingleUpdate($hash, "channel" . $1, $cmd1, 1) if ($cmd1 =~ m/^([A-D])./);
  2046. readingsSingleUpdate($hash, "channel" . $1, $cmd2, 1) if ($cmd2 && $cmd2 =~ m/^([A-D])./);
  2047. }
  2048. readingsSingleUpdate($hash, ".lastChannel", $lastChannel, 0);
  2049. }
  2050. } elsif ($st eq "switch.00") {
  2051. my $switchCmd = join(",", sort split(",", $cmd, 2));
  2052. ($cmd1, $cmd2) = split(",", $switchCmd, 2);
  2053. $cmd = $switchCmd;
  2054. if ((!defined($switchCmd)) || (!defined($EnO_switch_00Btn{$switchCmd}))) {
  2055. # check values
  2056. $cmdList .= join(":noArg ", keys %EnO_switch_00Btn);
  2057. return SetExtensions($hash, $cmdList, $name, @a);
  2058. } elsif ($switchCmd eq "teachIn") {
  2059. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, AttrVal($name, "comMode", "uniDir"),
  2060. AttrVal($name, "uteResponseRequest", "no"), "in", 0, "D2-03-00");
  2061. $updateState = 0;
  2062. } elsif ($switchCmd eq "teachInSec") {
  2063. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2064. ($err, $response, $logLevel) = EnOcean_sec_createTeachIn(undef, $hash, "uniDir", "VAES", "D2-03-00", 3,
  2065. "2++", "false", "encryption", $subDef, $destinationID);
  2066. if ($err) {
  2067. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  2068. return $err;
  2069. } else {
  2070. EnOcean_CommandSave(undef, undef);
  2071. Log3 $name, $logLevel, "EnOcean $name $response";
  2072. readingsSingleUpdate($hash, "teach", "STE teach-in sent", 1);
  2073. return(undef);
  2074. }
  2075. } elsif ($switchCmd eq "teachOut") {
  2076. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, AttrVal($name, "comMode", "uniDir"),
  2077. AttrVal($name, "uteResponseRequest", "no"), "out", 0, "D2-03-00");
  2078. $updateState = 0;
  2079. } else {
  2080. $data = sprintf "%02X", $EnO_switch_00Btn{$switchCmd};
  2081. $rorg = "D2";
  2082. #####
  2083. SetExtensionsCancel($hash);
  2084. }
  2085. Log3 $name, 3, "EnOcean set $name $switchCmd";
  2086. } elsif ($st eq "roomSensorControl.01") {
  2087. # Room Sensor and Control Unit (EEP A5-04-01, A5-10-10 ... A5-10-14)
  2088. # [Thermokon SR04 * rH, Thanus SR *, untested]
  2089. # $db[3] is the setpoint where 0x00 = min ... 0xFF = max
  2090. # $db[2] is the humidity where 0x00 = 0%rH ... 0xFA = 100%rH
  2091. # $db[1] is the temperature where 0x00 = 0°C ... 0xFA = +40°C
  2092. # $db[0] bit D0 is the occupy button, pushbutton or slide switch
  2093. $rorg = "A5";
  2094. # primarily temperature from the reference device then the attribute actualTemp is read
  2095. my $temperatureRefDev = AttrVal($name, "temperatureRefDev", undef);
  2096. my $actualTemp = AttrVal($name, "actualTemp", 20);
  2097. $actualTemp = ReadingsVal($temperatureRefDev, "temperature", 20) if (defined $temperatureRefDev);
  2098. $actualTemp = 20 if ($actualTemp !~ m/^[+-]?\d+(\.\d+)?$/);
  2099. $actualTemp = 0 if ($actualTemp < 0);
  2100. $actualTemp = 40 if ($actualTemp > 40);
  2101. $actualTemp = sprintf "%0.1f", $actualTemp;
  2102. # primarily humidity from the reference device then the attribute humidity is read
  2103. my $humidityRefDev = AttrVal($name, "humidityRefDev", undef);
  2104. my $humidity = AttrVal($name, "humidity", 0);
  2105. $humidity = ReadingsVal($humidityRefDev, "humidity", 0) if (defined $humidityRefDev);
  2106. $humidity = 0 if ($humidity !~ m/^\d+(\.\d+)?$/);
  2107. $humidity = 0 if ($humidity < 0);
  2108. $humidity = 100 if ($humidity > 100);
  2109. $humidity = sprintf "%d", $humidity;
  2110. my $setCmd = 8;
  2111. my $setpoint = ReadingsVal($name, "setpoint", 125);
  2112. my $setpointScaled = ReadingsVal($name, "setpointScaled", undef);
  2113. my $switch = ReadingsVal($name, "switch", "off");
  2114. $setCmd |= 1 if ($switch eq "on");
  2115. if ($cmd eq "teach") {
  2116. if ($manufID eq "00D") {
  2117. # teach-in EEP A5-10-12, Manufacturer "Eltako"
  2118. $data = "40900D80";
  2119. $attr{$name}{eep} = "A5-10-12";
  2120. } else {
  2121. # teach-in EEP A5-10-10, Manufacturer "Multi user Manufacturer ID"
  2122. $data = "4087FF80";
  2123. $attr{$name}{eep} = "A5-10-10";
  2124. }
  2125. CommandDeleteReading(undef, "$name .*");
  2126. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2127. $updateState = 0;
  2128. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2129. } elsif ($cmd eq "setpoint") {
  2130. #
  2131. if (defined $a[1]) {
  2132. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 255)) {
  2133. $setpoint = $a[1];
  2134. shift(@a);
  2135. if (defined $setpointScaled) {
  2136. $setpointScaled = EnOcean_ReadingScaled($hash, $setpoint, 0, 255);
  2137. }
  2138. } else {
  2139. return "Usage: $a[1] is not numeric or out of range";
  2140. }
  2141. }
  2142. readingsBeginUpdate($hash);
  2143. readingsBulkUpdate($hash, "temperature", $actualTemp);
  2144. readingsBulkUpdate($hash, "humidity", $humidity);
  2145. readingsBulkUpdate($hash, "setpointScaled", $setpointScaled) if (defined $setpointScaled);
  2146. readingsBulkUpdate($hash, "setpoint", $setpoint);
  2147. readingsBulkUpdate($hash, "switch", $switch);
  2148. readingsBulkUpdate($hash, "state", "T: $actualTemp H: $humidity SP: $setpoint SW: $switch");
  2149. readingsEndUpdate($hash, 1);
  2150. $actualTemp = $actualTemp / 40 * 250;
  2151. $humidity = $humidity / 100 * 250;
  2152. $updateState = 0;
  2153. $data = sprintf "%02X%02X%02X%02X", $setpoint, $humidity, $actualTemp, $setCmd;
  2154. } elsif ($cmd eq "setpointScaled") {
  2155. #
  2156. if (defined $a[1]) {
  2157. my $scaleMin = AttrVal($name, "scaleMin", undef);
  2158. my $scaleMax = AttrVal($name, "scaleMax", undef);
  2159. my ($rangeMin, $rangeMax);
  2160. if (defined $scaleMax && defined $scaleMin &&
  2161. $scaleMax =~ m/^[+-]?\d+(\.\d+)?$/ && $scaleMin =~ m/^[+-]?\d+(\.\d+)?$/) {
  2162. if ($scaleMin > $scaleMax) {
  2163. ($rangeMin, $rangeMax)= ($scaleMax, $scaleMin);
  2164. } else {
  2165. ($rangeMin, $rangeMax)= ($scaleMin, $scaleMax);
  2166. }
  2167. } else {
  2168. return "Usage: Attributes scaleMin and/or scaleMax not defined or not numeric.";
  2169. }
  2170. if ($a[1] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[1] >= $rangeMin && $a[1] <= $rangeMax) {
  2171. $setpointScaled = $a[1];
  2172. shift(@a);
  2173. $setpoint = sprintf "%d", 255 * $scaleMin/($scaleMin-$scaleMax) - 255/($scaleMin-$scaleMax) * $setpointScaled;
  2174. } else {
  2175. return "Usage: $a[1] is not numeric or out of range";
  2176. }
  2177. }
  2178. readingsBeginUpdate($hash);
  2179. readingsBulkUpdate($hash, "temperature", $actualTemp);
  2180. readingsBulkUpdate($hash, "humidity", $humidity);
  2181. readingsBulkUpdate($hash, "setpointScaled", $setpointScaled) if (defined $setpointScaled);
  2182. readingsBulkUpdate($hash, "setpoint", $setpoint);
  2183. readingsBulkUpdate($hash, "switch", $switch);
  2184. readingsBulkUpdate($hash, "state", "T: $actualTemp H: $humidity SP: $setpoint SW: $switch");
  2185. readingsEndUpdate($hash, 1);
  2186. $actualTemp = $actualTemp / 40 * 250;
  2187. $humidity = $humidity / 100 * 250;
  2188. $updateState = 0;
  2189. $data = sprintf "%02X%02X%02X%02X", $setpoint, $humidity, $actualTemp, $setCmd;
  2190. } elsif ($cmd eq "switch") {
  2191. #
  2192. if (defined $a[1]) {
  2193. if ($a[1] eq "on") {
  2194. $switch = $a[1];
  2195. $setCmd |= 1;
  2196. shift(@a);
  2197. } elsif ($a[1] eq "off"){
  2198. $switch = $a[1];
  2199. shift(@a);
  2200. } else {
  2201. return "Usage: $a[1] is unknown";
  2202. }
  2203. }
  2204. readingsBeginUpdate($hash);
  2205. readingsBulkUpdate($hash, "temperature", $actualTemp);
  2206. readingsBulkUpdate($hash, "humidity", $humidity);
  2207. readingsBulkUpdate($hash, "setpointScaled", $setpointScaled) if (defined $setpointScaled);
  2208. readingsBulkUpdate($hash, "setpoint", $setpoint);
  2209. readingsBulkUpdate($hash, "switch", $switch);
  2210. readingsBulkUpdate($hash, "state", "T: $actualTemp H: $humidity SP: $setpoint SW: $switch");
  2211. readingsEndUpdate($hash, 1);
  2212. $actualTemp = $actualTemp / 40 * 250;
  2213. $humidity = $humidity / 100 * 250;
  2214. $updateState = 0;
  2215. $data = sprintf "%02X%02X%02X%02X", $setpoint, $humidity, $actualTemp, $setCmd;
  2216. } else {
  2217. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . " setpoint:slider,0,1,255 setpointScaled switch:on,off teach:noArg"
  2218. }
  2219. Log3 $name, 3, "EnOcean set $name $cmd";
  2220. } elsif ($st eq "roomSensorControl.05") {
  2221. # Room Sensor and Control Unit (EEP A5-10-01 ... A5-10-0D)
  2222. # [Eltako FTR55D, FTR55H, Thermokon SR04 *, Thanos SR *, untested]
  2223. # $db[3] is the fan speed or night reduction for Eltako
  2224. # $db[2] is the setpoint where 0x00 = min ... 0xFF = max or
  2225. # reference temperature for Eltako where 0x00 = 0°C ... 0xFF = 40°C
  2226. # $db[1] is the temperature where 0x00 = +40°C ... 0xFF = 0°C
  2227. # $db[1]_bit_1 is blocking the aditional Room Sensor and Control Unit for Eltako FVS
  2228. # $db[0]_bit_0 is the slide switch
  2229. $rorg = "A5";
  2230. # primarily temperature from the reference device then the attribute actualTemp is read
  2231. my $temperatureRefDev = AttrVal($name, "temperatureRefDev", undef);
  2232. my $actualTemp = AttrVal($name, "actualTemp", 20);
  2233. $actualTemp = ReadingsVal($temperatureRefDev, "temperature", 20) if (defined $temperatureRefDev);
  2234. $actualTemp = 20 if ($actualTemp !~ m/^[+-]?\d+(\.\d+)?$/);
  2235. $actualTemp = 0 if ($actualTemp < 0);
  2236. $actualTemp = 40 if ($actualTemp > 40);
  2237. $actualTemp = sprintf "%0.1f", $actualTemp;
  2238. my $setCmd = 8;
  2239. if ($manufID eq "00D") {
  2240. # EEP A5-10-06 plus DB3 [Eltako FVS]
  2241. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  2242. my $nightReduction = ReadingsVal($name, "nightReduction", 0);
  2243. my $block = ReadingsVal($name, "block", "unlock");
  2244. if ($cmd eq "teach") {
  2245. # teach-in EEP A5-10-06 plus "FVS", Manufacturer "Eltako"
  2246. $data = "40300D85";
  2247. $attr{$name}{eep} = "A5-10-06";
  2248. CommandDeleteReading(undef, "$name .*");
  2249. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2250. $updateState = 0;
  2251. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2252. } elsif ($cmd eq "desired-temp" || $cmd eq "setpointTemp") {
  2253. #
  2254. if (defined $a[1]) {
  2255. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 40)) {
  2256. $setpointTemp = sprintf "%0.1f", $a[1];
  2257. shift(@a);
  2258. } else {
  2259. return "Usage: $a[1] is not numeric or out of range";
  2260. }
  2261. }
  2262. if (defined $a[1]) {
  2263. if (($a[1] =~ m/^(lock|unlock)$/) ) {
  2264. $block = $a[1];
  2265. shift(@a);
  2266. } else {
  2267. return "Usage: $a[1] is unknown";
  2268. }
  2269. }
  2270. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2271. readingsSingleUpdate($hash, "setpointTemp", $setpointTemp, 1);
  2272. readingsSingleUpdate($hash, "nightReduction", $nightReduction, 1);
  2273. readingsSingleUpdate($hash, "block", $block, 1);
  2274. readingsSingleUpdate($hash, "state", "T: $actualTemp SPT: $setpointTemp NR: $nightReduction", 1);
  2275. if ($nightReduction == 5) {
  2276. $nightReduction = 31;
  2277. } elsif ($nightReduction == 4) {
  2278. $nightReduction = 25;
  2279. } elsif ($nightReduction == 3) {
  2280. $nightReduction = 19;
  2281. } elsif ($nightReduction == 2) {
  2282. $nightReduction = 12;
  2283. } elsif ($nightReduction == 1) {
  2284. $nightReduction = 6;
  2285. } else {
  2286. $nightReduction = 0;
  2287. }
  2288. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2289. $setpointTemp = $setpointTemp * 255 / 40;
  2290. # control of the aditional Room Sensor and Control Unit
  2291. if ($block eq "lock") {
  2292. # temperature setting is locked
  2293. $setCmd = 0x0D;
  2294. } else {
  2295. # setpointTemp may be subject to change at +/-3 K
  2296. $setCmd = 0x0F;
  2297. }
  2298. $updateState = 0;
  2299. $data = sprintf "%02X%02X%02X%02X", $nightReduction, $setpointTemp, $actualTemp, $setCmd;
  2300. } elsif ($cmd eq "nightReduction") {
  2301. #
  2302. if (defined $a[1]) {
  2303. if ($a[1] =~ m/^[0-5]$/) {
  2304. $nightReduction = $a[1];
  2305. shift(@a);
  2306. } else {
  2307. return "Usage: $a[1] is not numeric or out of range";
  2308. }
  2309. }
  2310. if (defined $a[1]) {
  2311. if (($a[1] =~ m/^(lock|unlock)$/) ) {
  2312. $block = $a[1];
  2313. shift(@a);
  2314. } else {
  2315. return "Usage: $a[1] is unknown";
  2316. }
  2317. }
  2318. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2319. readingsSingleUpdate($hash, "setpointTemp", $setpointTemp, 1);
  2320. readingsSingleUpdate($hash, "nightReduction", $nightReduction, 1);
  2321. readingsSingleUpdate($hash, "block", $block, 1);
  2322. readingsSingleUpdate($hash, "state", "T: $actualTemp SPT: $setpointTemp NR: $nightReduction", 1);
  2323. if ($nightReduction == 5) {
  2324. $nightReduction = 31;
  2325. } elsif ($nightReduction == 4) {
  2326. $nightReduction = 25;
  2327. } elsif ($nightReduction == 3) {
  2328. $nightReduction = 19;
  2329. } elsif ($nightReduction == 2) {
  2330. $nightReduction = 12;
  2331. } elsif ($nightReduction == 1) {
  2332. $nightReduction = 6;
  2333. } else {
  2334. $nightReduction = 0;
  2335. }
  2336. $actualTemp = (40 - $actualTemp) / 40 * 254;
  2337. $setpointTemp = $setpointTemp * 254 / 40;
  2338. # control of the aditional Room Sensor and Control Unit
  2339. if ($block eq "lock") {
  2340. # temperature setting is locked
  2341. $setCmd = 0x0D;
  2342. } else {
  2343. # setpointTemp may be subject to change at +/-3 K
  2344. $setCmd = 0x0F;
  2345. }
  2346. $updateState = 0;
  2347. $data = sprintf "%02X%02X%02X%02X", $nightReduction, $setpointTemp, $actualTemp, $setCmd;
  2348. } else {
  2349. return "Unknown argument " . $cmd . ", choose one of setpointTemp:slider,0,1,40 desired-temp nightReduction:0,1,2,3,4,5 teach:noArg"
  2350. }
  2351. } else {
  2352. # EEP A5-10-02 or EEP A5-10-03
  2353. my $setpoint = ReadingsVal($name, "setpoint", 128);
  2354. my $setpointScaled = ReadingsVal($name, "setpointScaled", undef);
  2355. my $fanStage = ReadingsVal($name, "fanStage", "auto");
  2356. my $switch = ReadingsVal($name, "switch", "off");
  2357. $setCmd |= 1 if ($switch eq "on");
  2358. if ($cmd eq "teach") {
  2359. if ($manufID eq "019") {
  2360. # teach-in EEP A5-10-03, Manufacturer "Multi user Manufacturer ID"
  2361. $data = "401FFF80";
  2362. $attr{$name}{eep} = "A5-10-03";
  2363. } else {
  2364. # teach-in EEP A5-10-02, Manufacturer "Multi user Manufacturer ID"
  2365. $data = "4017FF80";
  2366. $attr{$name}{eep} = "A5-10-02";
  2367. }
  2368. CommandDeleteReading(undef, "$name .*");
  2369. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2370. $updateState = 0;
  2371. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2372. } elsif ($cmd eq "fanStage") {
  2373. #
  2374. if (defined $a[1] && ($a[1] =~ m/^[0-3]$/ || $a[1] eq "auto")) {
  2375. $fanStage = $a[1];
  2376. shift(@a);
  2377. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2378. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1) if (defined $setpointScaled);
  2379. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2380. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2381. readingsSingleUpdate($hash, "switch", $switch, 1);
  2382. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2383. if ($fanStage eq "auto"){
  2384. $fanStage = 255;
  2385. } elsif ($fanStage == 0) {
  2386. $fanStage = 209;
  2387. } elsif ($fanStage == 1) {
  2388. $fanStage = 189;
  2389. } elsif ($fanStage == 2) {
  2390. $fanStage = 164;
  2391. } else {
  2392. $fanStage = 144;
  2393. }
  2394. } else {
  2395. return "Usage: $a[1] is not numeric, out of range or unknown";
  2396. }
  2397. $actualTemp = (40 - $actualTemp) / 40 * 254;
  2398. $updateState = 0;
  2399. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2400. } elsif ($cmd eq "setpoint") {
  2401. #
  2402. if (defined $a[1]) {
  2403. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 255)) {
  2404. $setpoint = $a[1];
  2405. shift(@a);
  2406. if (defined $setpointScaled) {
  2407. $setpointScaled = EnOcean_ReadingScaled($hash, $setpoint, 0, 255);
  2408. }
  2409. } else {
  2410. return "Usage: $a[1] is not numeric or out of range";
  2411. }
  2412. }
  2413. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2414. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1) if (defined $setpointScaled);
  2415. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2416. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2417. readingsSingleUpdate($hash, "switch", $switch, 1);
  2418. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2419. if ($fanStage eq "auto"){
  2420. $fanStage = 255;
  2421. } elsif ($fanStage == 0) {
  2422. $fanStage = 209;
  2423. } elsif ($fanStage == 1) {
  2424. $fanStage = 189;
  2425. } elsif ($fanStage == 2) {
  2426. $fanStage = 164;
  2427. } else {
  2428. $fanStage = 144;
  2429. }
  2430. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2431. $updateState = 0;
  2432. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2433. } elsif ($cmd eq "setpointScaled") {
  2434. #
  2435. if (defined $a[1]) {
  2436. my $scaleMin = AttrVal($name, "scaleMin", undef);
  2437. my $scaleMax = AttrVal($name, "scaleMax", undef);
  2438. my ($rangeMin, $rangeMax);
  2439. if (defined $scaleMax && defined $scaleMin &&
  2440. $scaleMax =~ m/^[+-]?\d+(\.\d+)?$/ && $scaleMin =~ m/^[+-]?\d+(\.\d+)?$/) {
  2441. if ($scaleMin > $scaleMax) {
  2442. ($rangeMin, $rangeMax)= ($scaleMax, $scaleMin);
  2443. } else {
  2444. ($rangeMin, $rangeMax)= ($scaleMin, $scaleMax);
  2445. }
  2446. } else {
  2447. return "Usage: Attributes scaleMin and/or scaleMax not defined or not numeric.";
  2448. }
  2449. if ($a[1] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[1] >= $rangeMin && $a[1] <= $rangeMax) {
  2450. $setpointScaled = $a[1];
  2451. shift(@a);
  2452. $setpoint = sprintf "%d", 255 * $scaleMin/($scaleMin-$scaleMax) - 255/($scaleMin-$scaleMax) * $setpointScaled;
  2453. } else {
  2454. return "Usage: $a[1] is not numeric or out of range";
  2455. }
  2456. }
  2457. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2458. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1);
  2459. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2460. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2461. readingsSingleUpdate($hash, "switch", $switch, 1);
  2462. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2463. if ($fanStage eq "auto"){
  2464. $fanStage = 255;
  2465. } elsif ($fanStage == 0) {
  2466. $fanStage = 209;
  2467. } elsif ($fanStage == 1) {
  2468. $fanStage = 189;
  2469. } elsif ($fanStage == 2) {
  2470. $fanStage = 164;
  2471. } else {
  2472. $fanStage = 144;
  2473. }
  2474. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2475. $updateState = 0;
  2476. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2477. } elsif ($cmd eq "switch") {
  2478. #
  2479. if (defined $a[1]) {
  2480. if ($a[1] eq "on") {
  2481. $switch = $a[1];
  2482. $setCmd |= 1;
  2483. shift(@a);
  2484. } elsif ($a[1] eq "off"){
  2485. $switch = $a[1];
  2486. shift(@a);
  2487. } else {
  2488. return "Usage: $a[1] is unknown";
  2489. }
  2490. }
  2491. readingsSingleUpdate($hash, "temperature", $actualTemp, 1);
  2492. readingsSingleUpdate($hash, "setpointScaled", $setpointScaled, 1) if (defined $setpointScaled);
  2493. readingsSingleUpdate($hash, "setpoint", $setpoint, 1);
  2494. readingsSingleUpdate($hash, "fanStage", $fanStage, 1);
  2495. readingsSingleUpdate($hash, "switch", $switch, 1);
  2496. readingsSingleUpdate($hash, "state", "T: $actualTemp SP: $setpoint F: $fanStage SW: $switch", 1);
  2497. if ($fanStage eq "auto"){
  2498. $fanStage = 255;
  2499. } elsif ($fanStage == 0) {
  2500. $fanStage = 209;
  2501. } elsif ($fanStage == 1) {
  2502. $fanStage = 189;
  2503. } elsif ($fanStage == 2) {
  2504. $fanStage = 164;
  2505. } else {
  2506. $fanStage = 144;
  2507. }
  2508. $actualTemp = (40 - $actualTemp) / 40 * 255;
  2509. $updateState = 0;
  2510. $data = sprintf "%02X%02X%02X%02X", $fanStage, $setpoint, $actualTemp, $setCmd;
  2511. } else {
  2512. 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"
  2513. }
  2514. }
  2515. Log3 $name, 3, "EnOcean set $name $cmd";
  2516. } elsif ($st eq "hvac.01" || $st eq "MD15") {
  2517. # Battery Powered Actuator (EEP A5-20-01)
  2518. # [Kieback&Peter MD15-FTL-xx]
  2519. $rorg = "A5";
  2520. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  2521. my $temperature = ReadingsVal($name, "temperature", 20);
  2522. if ($cmd eq "setpoint") {
  2523. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  2524. readingsBeginUpdate($hash);
  2525. readingsBulkUpdate($hash, "setpointSet", $a[1]);
  2526. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2527. readingsEndUpdate($hash, 0);
  2528. # stop PID regulator
  2529. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2530. CommandDeleteReading(undef, "$name setpointTempSet");
  2531. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  2532. shift(@a);
  2533. } else {
  2534. return "Usage: $cmd value wrong.";
  2535. }
  2536. $updateState = 2;
  2537. } elsif ($cmd =~ m/^desired-temp|setpointTemp$/) {
  2538. if (defined $a[1] && $a[1] =~ m/^\d+(\.\d)?$/ && $a[1] >= 10 && $a[1] <= 30) {
  2539. $cmd = "setpointTemp";
  2540. $setpointTemp = $a[1];
  2541. readingsBeginUpdate($hash);
  2542. readingsBulkUpdate($hash, "setpointTempSet", sprintf("%0.1f", $setpointTemp));
  2543. readingsBulkUpdate($hash, "waitingCmds", "setpointTemp");
  2544. readingsEndUpdate($hash, 0);
  2545. # PID regulator active
  2546. my $activatePID = AttrVal($name, 'pidCtrl', 'off') eq 'on' ? 'start' : 'stop';
  2547. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  2548. CommandDeleteReading(undef, "$name setpointSet");
  2549. Log3 $name, 3, "EnOcean set $name $cmd $setpointTemp";
  2550. shift(@a);
  2551. } else {
  2552. return "Usage: $cmd value wrong.";
  2553. }
  2554. $updateState = 2;
  2555. } elsif ($cmd =~ m/^liftSet|runInit|valveOpens|valveCloses$/) {
  2556. # unattended?
  2557. readingsBeginUpdate($hash);
  2558. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2559. readingsEndUpdate($hash, 0);
  2560. # stop PID regulator
  2561. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2562. CommandDeleteReading(undef, "$name setpointSet");
  2563. CommandDeleteReading(undef, "$name setpointTempSet");
  2564. Log3 $name, 3, "EnOcean set $name $cmd";
  2565. $updateState = 2;
  2566. } else {
  2567. $cmdList .= "setpointTemp:slider,0,1,40 " if (AttrVal($name, "pidCtrl", 'on') eq 'on' || AttrVal($name, "manufID", '7FF') ne '049');
  2568. $cmdList .= "setpoint:slider,0,5,100 desired-temp liftSet:noArg runInit:noArg valveOpens:noArg valveCloses:noArg";
  2569. return "Unknown command " . $cmd . ", choose one of " . $cmdList;
  2570. }
  2571. } elsif ($st eq "hvac.04") {
  2572. # heating radiator valve actuating drive (EEP A5-20-04)
  2573. $rorg = "A5";
  2574. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  2575. my $temperature = ReadingsVal($name, "temperature", 20);
  2576. if ($cmd eq "setpoint") {
  2577. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  2578. readingsBeginUpdate($hash);
  2579. readingsBulkUpdate($hash, "setpointSet", $a[1]);
  2580. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2581. readingsEndUpdate($hash, 0);
  2582. # stop PID regulator
  2583. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2584. CommandDeleteReading(undef, "$name setpointTempSet");
  2585. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  2586. shift(@a);
  2587. } else {
  2588. return "Usage: $cmd value wrong.";
  2589. }
  2590. $updateState = 2;
  2591. } elsif ($cmd =~ m/^desired-temp|setpointTemp$/) {
  2592. if (defined $a[1] && $a[1] =~ m/^\d+(\.\d)?$/ && $a[1] >= 10 && $a[1] <= 30) {
  2593. $cmd = "setpointTemp";
  2594. $setpointTemp = $a[1];
  2595. readingsBeginUpdate($hash);
  2596. readingsBulkUpdate($hash, "setpointTempSet", sprintf("%0.1f", $setpointTemp));
  2597. readingsBulkUpdate($hash, "waitingCmds", "setpointTemp");
  2598. readingsEndUpdate($hash, 0);
  2599. # PID regulator active
  2600. #####
  2601. my $activatePID = AttrVal($name, 'pidCtrl', 'on') eq 'on' ? 'start' : 'stop';
  2602. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  2603. CommandDeleteReading(undef, "$name setpointSet");
  2604. Log3 $name, 3, "EnOcean set $name $cmd $setpointTemp";
  2605. shift(@a);
  2606. } else {
  2607. return "Usage: $cmd value wrong.";
  2608. }
  2609. $updateState = 2;
  2610. } elsif ($cmd =~ m/^runInit|valveOpens|valveCloses$/) {
  2611. readingsBeginUpdate($hash);
  2612. readingsBulkUpdate($hash, "waitingCmds", $cmd);
  2613. readingsEndUpdate($hash, 0);
  2614. # stop PID regulator
  2615. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  2616. CommandDeleteReading(undef, "$name setpointSet");
  2617. CommandDeleteReading(undef, "$name setpointTempSet");
  2618. Log3 $name, 3, "EnOcean set $name $cmd";
  2619. $updateState = 2;
  2620. } else {
  2621. $cmdList .= "setpointTemp:slider,10,1,30 " if (AttrVal($name, "pidCtrl", 'on') eq 'on' || AttrVal($name, "model", '') eq 'OEM');
  2622. $cmdList .= "setpoint:slider,0,5,100 " if (AttrVal($name, "pidCtrl", 'on') eq 'off' && AttrVal($name, "model", '') ne 'OEM');
  2623. $cmdList .= "runInit:noArg valveCloses:noArg valveOpens:noArg";
  2624. return "Unknown command " . $cmd . ", choose one of " . $cmdList;
  2625. }
  2626. } elsif ($st eq "hvac.10") {
  2627. # Generic HVAC Interface (EEP A5-20-10)
  2628. $rorg = "A5";
  2629. my %ctrlFunc = (
  2630. "off" => 1,
  2631. "on" => 2,
  2632. "occupancy" => 3,
  2633. "ctrl" => 4,
  2634. "fanSpeed" => 5,
  2635. "vanePosition" => 6,
  2636. "mode" => 7,
  2637. "teach" => 255,
  2638. );
  2639. my %mode = (
  2640. "auto" => 0,
  2641. "heat" => 1,
  2642. "morning_warmup" => 2,
  2643. "cool" => 3,
  2644. "night_purge" => 4,
  2645. "precool" => 5,
  2646. "off" => 6,
  2647. "test" => 7,
  2648. "emergency_heat" => 8,
  2649. "fan_only" => 9,
  2650. "free_cool" => 10,
  2651. "ice" => 11,
  2652. "max_heat" => 12,
  2653. "eco" => 13,
  2654. "dehumidification" => 14,
  2655. "calibration" => 15,
  2656. "emergency_cool" => 16,
  2657. "emergency_stream" => 17,
  2658. "max_cool" => 18,
  2659. "hvc_load" => 19,
  2660. "no_load" => 20,
  2661. "auto_heat" => 31,
  2662. "auto_cool" => 32,
  2663. );
  2664. my %vanePosition = (
  2665. "auto" => 0,
  2666. "horizontal" => 1,
  2667. "position_2" => 2,
  2668. "position_3" => 3,
  2669. "position_4" => 4,
  2670. "vertical" => 5,
  2671. "swing" => 6,
  2672. "vertical_swing" => 11,
  2673. "horizontal_swing" => 12,
  2674. "hor_vert_swing" => 13,
  2675. "stop_swing" => 14,
  2676. );
  2677. my $ctrlFuncID;
  2678. if (defined $ctrlFunc{$cmd}) {
  2679. $ctrlFuncID = $ctrlFunc{$cmd};
  2680. } else {
  2681. $cmdList .= "ctrl mode:" . join(",", sort keys %mode) . " fanSpeed:auto,1,2,3,4,5,6,7,8,9,10,11,12,13,14 " .
  2682. "occupancy:occupied,off,standby,unoccupied on:noArg off:noArg teach:noArg vanePosition:" .
  2683. join(",", sort keys %vanePosition);
  2684. return SetExtensions ($hash, $cmdList, $name, @a);
  2685. }
  2686. $ctrl = ReadingsVal($name, "ctrl", "auto");
  2687. my $fanSpeed = ReadingsVal($name, "fanSpeed", "auto");
  2688. my $mode = ReadingsVal($name, "mode", "off");
  2689. my $occupancy = ReadingsVal($name, "occupancy", "off");
  2690. my $powerSwitch = ReadingsVal($name, "powerSwitch", "off");
  2691. my $vanePosition = ReadingsVal($name, "vanePosition", "auto");
  2692. my ($ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd) = (0, 0, 0, 8);
  2693. if($ctrlFuncID == 255) {
  2694. # teach-in EEP A5-20-10, Manufacturer "Multi user Manufacturer ID"
  2695. $ctrlParam1 = 0x80;
  2696. $ctrlParam2 = 0x87;
  2697. $ctrlParam3 = 0xFF;
  2698. $setCmd = 0x80;
  2699. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  2700. EnOcean_4BSRespWait(undef, $hash, $subDef);
  2701. readingsSingleUpdate($hash, "teach", "4BS teach-in sent, response requested", 1);
  2702. $updateState = 0;
  2703. } elsif ($ctrlFuncID == 1) {
  2704. # off
  2705. $powerSwitch = "off";
  2706. $updateState = 0;
  2707. readingsBeginUpdate($hash);
  2708. readingsBulkUpdate($hash, "powerSwitch", "off");
  2709. readingsBulkUpdate($hash, "state", "off");
  2710. readingsEndUpdate($hash, 0);
  2711. #####
  2712. SetExtensionsCancel($hash);
  2713. } elsif ($ctrlFuncID == 2) {
  2714. # on
  2715. $powerSwitch = "on";
  2716. $updateState = 0;
  2717. readingsBeginUpdate($hash);
  2718. readingsBulkUpdate($hash, "powerSwitch", "on");
  2719. readingsBulkUpdate($hash, "state", "off");
  2720. readingsEndUpdate($hash, 0);
  2721. #####
  2722. SetExtensionsCancel($hash);
  2723. } elsif ($ctrlFuncID == 3) {
  2724. # occupancy
  2725. if (defined $a[1] && $a[1] =~ m/^occupied|standby|unoccupied|off$/) {
  2726. $occupancy = $a[1];
  2727. readingsSingleUpdate($hash, "occupancy", $a[1], 0);
  2728. shift(@a);
  2729. } else {
  2730. return "Usage: $cmd value wrong.";
  2731. }
  2732. $updateState = 0;
  2733. } elsif ($ctrlFuncID == 4) {
  2734. # ctrl
  2735. if (defined $a[1] && ($a[1] =~ m/^auto$/ || $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100)) {
  2736. $ctrl = $a[1];
  2737. readingsSingleUpdate($hash, "ctrl", $a[1], 0);
  2738. shift(@a);
  2739. } else {
  2740. return "Usage: $cmd value wrong.";
  2741. }
  2742. $updateState = 0;
  2743. } elsif ($ctrlFuncID == 5) {
  2744. # fanSpeed
  2745. if (defined $a[1] && ($a[1] =~ m/^auto$/ || $a[1] =~ m/^\d+$/ && $a[1] > 0 && $a[1] < 15)) {
  2746. $fanSpeed = $a[1];
  2747. readingsSingleUpdate($hash, "fanSpeed", $a[1], 0);
  2748. shift(@a);
  2749. } else {
  2750. return "Usage: $cmd value wrong.";
  2751. }
  2752. $updateState = 0;
  2753. } elsif ($ctrlFuncID == 6) {
  2754. # vanePosition
  2755. my $vanePositionValues = join("|", keys %vanePosition);
  2756. if (defined $a[1] && $a[1] =~ m/^$vanePositionValues$/) {
  2757. $vanePosition = $a[1];
  2758. readingsSingleUpdate($hash, "vanePosition", $a[1], 0);
  2759. shift(@a);
  2760. } else {
  2761. return "Usage: $cmd value wrong.";
  2762. }
  2763. $updateState = 0;
  2764. } elsif ($ctrlFuncID == 7) {
  2765. # mode
  2766. my $modeValues = join("|", keys %mode);
  2767. if (defined $a[1] && $a[1] =~ m/^$modeValues$/) {
  2768. $mode = $a[1];
  2769. readingsSingleUpdate($hash, "mode", $a[1], 0);
  2770. shift(@a);
  2771. } else {
  2772. return "Usage: $cmd value wrong.";
  2773. }
  2774. $updateState = 0;
  2775. }
  2776. if ($cmd ne "teach") {
  2777. $ctrlParam1 = $mode{$mode};
  2778. $vanePosition = $vanePosition{$vanePosition};
  2779. $fanSpeed = 0 if ($fanSpeed eq "auto");
  2780. $ctrlParam2 = $vanePosition << 4 || $fanSpeed;
  2781. $ctrl = 255 if ($ctrl eq "auto");
  2782. $ctrlParam3 = $ctrl;
  2783. if ($occupancy eq "occupied") {
  2784. $occupancy = 0;
  2785. } elsif ($occupancy eq "standby") {
  2786. $occupancy = 1;
  2787. } elsif ($occupancy eq "unoccupied") {
  2788. $occupancy = 2;
  2789. } else {
  2790. $occupancy = 3;
  2791. }
  2792. $powerSwitch = $powerSwitch eq "on" ? 1 : 0;
  2793. $setCmd |= $occupancy << 1 | $powerSwitch;
  2794. }
  2795. $data = sprintf "%02X%02X%02X%02X", $ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd;
  2796. Log3 $name, 3, "EnOcean set $name $cmd";
  2797. } elsif ($st eq "hvac.11") {
  2798. # Generic HVAC Interface - Error Control (EEP A5-20-11)
  2799. $rorg = "A5";
  2800. my %ctrlFunc = (
  2801. "externalDisable" => 1,
  2802. "remoteCtrl" => 2,
  2803. "window" => 3,
  2804. "teach" => 255,
  2805. );
  2806. my $ctrlFuncID;
  2807. if (defined $ctrlFunc{$cmd}) {
  2808. $ctrlFuncID = $ctrlFunc{$cmd};
  2809. } else {
  2810. $cmdList .= "externalDisable:disabled,enabled remoteCtrl:disabled,enabled teach:noArg window:closed,opened";
  2811. return "Unknown argument " . $cmd . ", choose one of " . $cmdList;
  2812. }
  2813. my $extern = ReadingsVal($name, "externalDisable", "enable");
  2814. my $remote = ReadingsVal($name, "remoteCtrl", "enable");
  2815. my $window = ReadingsVal($name, "window", "closed");
  2816. my ($ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd) = (0, 0, 0, 8);
  2817. if($ctrlFuncID == 255) {
  2818. # teach-in EEP A5-20-11, Manufacturer "Multi user Manufacturer ID"
  2819. $ctrlParam1 = 0x80;
  2820. $ctrlParam2 = 0x8F;
  2821. $ctrlParam3 = 0xFF;
  2822. $setCmd = 0x80;
  2823. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  2824. EnOcean_4BSRespWait(undef, $hash, $subDef);
  2825. readingsSingleUpdate($hash, "teach", "4BS teach-in sent, response requested", 1);
  2826. $updateState = 0;
  2827. } elsif ($ctrlFuncID == 1) {
  2828. # external disablement
  2829. if (defined $a[1] && $a[1] =~ m/^disabled|enabled$/) {
  2830. $extern = $a[1];
  2831. readingsSingleUpdate($hash, "externalDisable", $a[1], 0);
  2832. shift(@a);
  2833. } else {
  2834. return "Usage: $cmd value wrong.";
  2835. }
  2836. $updateState = 0;
  2837. } elsif ($ctrlFuncID == 2) {
  2838. # disable remote controller
  2839. if (defined $a[1] && $a[1] =~ m/^disabled|enabled$/) {
  2840. $remote = $a[1];
  2841. readingsSingleUpdate($hash, "remoteCtrl", $a[1], 0);
  2842. shift(@a);
  2843. } else {
  2844. return "Usage: $cmd value wrong.";
  2845. }
  2846. $updateState = 0;
  2847. } elsif ($ctrlFuncID == 3) {
  2848. # window contact
  2849. if (defined $a[1] && $a[1] =~ m/^closed|opened$/) {
  2850. $window = $a[1];
  2851. readingsSingleUpdate($hash, "window", $a[1], 0);
  2852. shift(@a);
  2853. } else {
  2854. return "Usage: $cmd value wrong.";
  2855. }
  2856. $updateState = 0;
  2857. }
  2858. if ($cmd ne "teach") {
  2859. $ctrlParam3 = $extern eq "disabled" ? 1 : 0;
  2860. $setCmd |= ($remote eq "disabled" ? 1 : 0) << 2 | ($window eq "closed" ? 1 : 0) << 1;
  2861. }
  2862. $data = sprintf "%02X%02X%02X%02X", $ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd;
  2863. Log3 $name, 3, "EnOcean set $name $cmd";
  2864. } elsif ($st eq "gateway") {
  2865. # Gateway (EEP A5-38-08)
  2866. # select Command from attribute gwCmd or command line
  2867. my $gwCmd = AttrVal($name, "gwCmd", undef);
  2868. if ($gwCmd && $EnO_gwCmd{$gwCmd}) {
  2869. # command from attribute gwCmd
  2870. if ($EnO_gwCmd{$cmd}) {
  2871. # shift $cmd
  2872. $cmd = $a[1];
  2873. shift(@a);
  2874. }
  2875. } elsif ($EnO_gwCmd{$cmd}) {
  2876. # command from command line
  2877. $gwCmd = $cmd;
  2878. $cmd = $a[1];
  2879. shift(@a);
  2880. } else {
  2881. return "Unknown Gateway command " . $cmd . ", choose one of " . $cmdList . join(" ", sort keys %EnO_gwCmd);
  2882. }
  2883. my $gwCmdID;
  2884. $rorg = "A5";
  2885. my $setCmd = 0;
  2886. my $time = 0;
  2887. if ($gwCmd eq "switching") {
  2888. # Switching
  2889. $gwCmdID = 1;
  2890. if($cmd eq "teach") {
  2891. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  2892. #$data = sprintf "%02X000000", $gwCmdID;
  2893. if ($model eq 'TF') {
  2894. $data = "E0400D80";
  2895. } else {
  2896. $data = "E047FF80";
  2897. }
  2898. $attr{$name}{eep} = "A5-38-08";
  2899. CommandDeleteReading(undef, "$name .*");
  2900. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2901. $updateState = 0;
  2902. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2903. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  2904. } elsif ($cmd eq "on") {
  2905. $setCmd = 9;
  2906. readingsSingleUpdate($hash, "block", "unlock", 1);
  2907. if ($a[1]) {
  2908. return "Usage: $cmd [lock|unlock]" if (($a[1] ne "lock") && ($a[1] ne "unlock"));
  2909. if ($a[1] eq "lock") {
  2910. $setCmd = $setCmd | 4;
  2911. readingsSingleUpdate($hash, "block", "lock", 1);
  2912. }
  2913. shift(@a);
  2914. }
  2915. #$updateState = 0;
  2916. #####
  2917. SetExtensionsCancel($hash);
  2918. $data = sprintf "%02X%04X%02X", $gwCmdID, $time, $setCmd;
  2919. } elsif ($cmd eq "off") {
  2920. if ($model eq "FSA12") {
  2921. $setCmd = 0x0E;
  2922. } else {
  2923. $setCmd = 8;
  2924. }
  2925. readingsSingleUpdate($hash, "block", "unlock", 1);
  2926. if ($a[1]) {
  2927. return "Usage: $cmd [lock|unlock]" if (($a[1] ne "lock") && ($a[1] ne "unlock"));
  2928. if ($a[1] eq "lock") {
  2929. $setCmd = $setCmd | 4;
  2930. readingsSingleUpdate($hash, "block", "lock", 1);
  2931. }
  2932. shift(@a);
  2933. }
  2934. #$updateState = 0;
  2935. #####
  2936. SetExtensionsCancel($hash);
  2937. $data = sprintf "%02X%04X%02X", $gwCmdID, $time, $setCmd;
  2938. } elsif ($cmd eq "local") {
  2939. if ($a[1]) {
  2940. return "Usage: $cmd [learn]" if ($a[1] ne "learn");
  2941. if ($a[1] eq "learn") {
  2942. $cmd = 'off';
  2943. $setCmd = $setCmd | 0x28;
  2944. readingsSingleUpdate($hash, "block", "unlock", 1);
  2945. }
  2946. shift(@a);
  2947. }
  2948. #$updateState = 0;
  2949. $data = sprintf "%02X%04X%02X", $gwCmdID, $time, $setCmd;
  2950. } else {
  2951. my $cmdList = "local:learn on:noArg off:noArg teach:noArg";
  2952. return SetExtensions ($hash, $cmdList, $name, @a);
  2953. }
  2954. } elsif ($gwCmd eq "dimming") {
  2955. # Dimming
  2956. $gwCmdID = 2;
  2957. my $dimMax = AttrVal($name, "dimMax", 255);
  2958. my $dimMin = AttrVal($name, "dimMin", "off");
  2959. if ($dimMax =~ m/^\d+$/ && $dimMin =~ m/^\d+$/ && $dimMin > $dimMax) {
  2960. ($dimMax, $dimMin) = ($dimMin , $dimMax);
  2961. }
  2962. my $dimVal = ReadingsVal($name, "dim", undef);
  2963. my $rampTime = AttrVal($name, "rampTime", 1);
  2964. my $sendDimCmd = 0;
  2965. $setCmd = 9;
  2966. if ($cmd =~ m/^\d+$/) {
  2967. # interpretive numeric value as dimming
  2968. unshift(@a, 'dim');
  2969. $cmd = 'dim';
  2970. }
  2971. if ($cmd eq "teach") {
  2972. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  2973. #$data = "E047FF80";
  2974. # teach-in Eltako
  2975. if ($model eq 'TF') {
  2976. $data = "E0400D80";
  2977. } else {
  2978. $data = "02000000";
  2979. }
  2980. $attr{$name}{eep} = "A5-38-08";
  2981. CommandDeleteReading(undef, "$name .*");
  2982. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  2983. $updateState = 0;
  2984. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  2985. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  2986. } elsif ($cmd eq "dim") {
  2987. return "Usage: $cmd dim/% [rampTime/s lock|unlock]"
  2988. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  2989. # for eltako relative (0-100) (but not compliant to EEP because DB0.2 is 0)
  2990. # >> if manufID needed: set DB2.0
  2991. $dimVal = $a[1];
  2992. if ($dimVal > 0) {
  2993. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  2994. }
  2995. shift(@a);
  2996. if (defined($a[1])) {
  2997. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] !~ m/^\d+$/);
  2998. $rampTime = $a[1];
  2999. shift(@a);
  3000. }
  3001. $sendDimCmd = 1;
  3002. } elsif ($cmd eq "dimup") {
  3003. return "Usage: $cmd dim/% [rampTime/s lock|unlock]"
  3004. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3005. $dimVal += $a[1];
  3006. if ($dimVal > 0) {
  3007. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3008. }
  3009. shift(@a);
  3010. if (defined($a[1])) {
  3011. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] !~ m/^\d+$/);
  3012. $rampTime = $a[1];
  3013. shift(@a);
  3014. }
  3015. $sendDimCmd = 1;
  3016. } elsif ($cmd eq "dimdown") {
  3017. return "Usage: $cmd dim/% [rampTime/s lock|unlock]"
  3018. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3019. $dimVal -= $a[1];
  3020. if ($dimVal > 0) {
  3021. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3022. }
  3023. shift(@a);
  3024. if (defined($a[1])) {
  3025. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] !~ m/^\d+$/);
  3026. $rampTime = $a[1];
  3027. shift(@a);
  3028. }
  3029. $sendDimCmd = 1;
  3030. } elsif ($cmd eq "on") {
  3031. $rampTime = 1;
  3032. my $dimValueOn = AttrVal($name, "dimValueOn", 100);
  3033. if ($dimValueOn eq "stored") {
  3034. $dimVal = ReadingsVal($name, "dimValueStored", 100);
  3035. if ($dimVal < 1) {
  3036. $dimVal = 100;
  3037. readingsSingleUpdate ($hash, "dimValueStored", $dimVal, 1);
  3038. }
  3039. } elsif ($dimValueOn eq "last") {
  3040. $dimVal = ReadingsVal ($name, "dimValueLast", 100);
  3041. if ($dimVal < 1) { $dimVal = 100; }
  3042. } else {
  3043. if ($dimValueOn !~ m/^\d+$/) {
  3044. $dimVal = 100;
  3045. } elsif ($dimValueOn > 100) {
  3046. $dimVal = 100;
  3047. } elsif ($dimValueOn < 1) {
  3048. $dimVal = 1;
  3049. } else {
  3050. $dimVal = $dimValueOn;
  3051. }
  3052. }
  3053. $sendDimCmd = 1;
  3054. } elsif ($cmd eq "off") {
  3055. $dimVal = 0;
  3056. $rampTime = 1;
  3057. $setCmd = 8;
  3058. $sendDimCmd = 1;
  3059. } elsif ($cmd eq "local") {
  3060. if ($a[1]) {
  3061. return "Usage: $cmd [learn]" if ($a[1] ne "learn");
  3062. if ($a[1] eq "learn") {
  3063. $cmd = 'off';
  3064. $dimVal = 0;
  3065. $rampTime = 1;
  3066. $setCmd = 0x2C;
  3067. readingsSingleUpdate($hash, "block", "lock", 1);
  3068. }
  3069. shift(@a);
  3070. }
  3071. #$updateState = 0;
  3072. #####
  3073. SetExtensionsCancel($hash);
  3074. $data = sprintf "%02X%02X%02X%02X", $gwCmdID, $dimVal, $rampTime, $setCmd;
  3075. } else {
  3076. my $cmdList = "dim:slider,0,1,100 local:learn on:noArg off:noArg teach:noArg";
  3077. return SetExtensions ($hash, $cmdList, $name, @a);
  3078. }
  3079. if ($sendDimCmd) {
  3080. readingsSingleUpdate($hash, "block", "unlock", 1);
  3081. if (defined $a[1]) {
  3082. return "Usage: $cmd dim/% [rampTime/s lock|unlock]" if ($a[1] ne "lock" && $a[1] ne "unlock");
  3083. # Eltako devices: lock dimming value
  3084. if ($manufID eq "00D" && $a[1] eq "lock" ) {
  3085. $setCmd = $setCmd | 4;
  3086. readingsSingleUpdate($hash, "block", "lock", 1);
  3087. }
  3088. shift(@a);
  3089. } else {
  3090. # Dimming value relative
  3091. if ($manufID ne "00D") {$setCmd = $setCmd | 4;}
  3092. }
  3093. if ($cmd eq "off" && $dimMin =~ m/^\d+$/ && $dimMin == 0) {
  3094. # switch off
  3095. } elsif ($cmd eq "off" && $dimMin =~ m/^\d+$/) {
  3096. $dimVal = $dimMin;
  3097. $setCmd = 9;
  3098. } elsif ($dimMax eq "off" || $dimVal == 0 && $dimMin eq "off" || $dimVal < 0) {
  3099. # switch off
  3100. $dimVal = 0;
  3101. $setCmd = 8;
  3102. } elsif ($dimMin eq "off") {
  3103. } elsif ($dimVal < $dimMin) {
  3104. $dimVal = $dimMin;
  3105. }
  3106. $dimVal = $dimMax if ($dimVal > $dimMax);
  3107. $dimVal = 100 if ($dimVal > 100);
  3108. $rampTime = 0 if ($rampTime < 0);
  3109. $rampTime = 255 if ($rampTime > 255);
  3110. #$updateState = 0;
  3111. readingsSingleUpdate ($hash, "dim", $dimVal, 1);
  3112. $data = sprintf "%02X%02X%02X%02X", $gwCmdID, $dimVal, $rampTime, $setCmd;
  3113. }
  3114. } elsif ($gwCmd eq "setpointShift") {
  3115. $gwCmdID = 3;
  3116. if ($cmd eq "teach") {
  3117. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3118. $data = "E047FF80";
  3119. $attr{$name}{eep} = "A5-38-08";
  3120. CommandDeleteReading(undef, "$name .*");
  3121. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3122. $updateState = 0;
  3123. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3124. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3125. } elsif ($cmd eq "shift") {
  3126. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= -12.7) && ($a[1] <= 12.8)) {
  3127. #$updateState = 0;
  3128. $data = sprintf "%02X00%02X08", $gwCmdID, ($a[1] + 12.7) * 10;
  3129. shift(@a);
  3130. } else {
  3131. return "Usage: $a[1] is not numeric or out of range";
  3132. }
  3133. } else {
  3134. return "Unknown argument $cmd, choose one of teach:noArg shift";
  3135. }
  3136. } elsif ($gwCmd eq "setpointBasic") {
  3137. $gwCmdID = 4;
  3138. if($cmd eq "teach") {
  3139. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3140. $data = "E047FF80";
  3141. $attr{$name}{eep} = "A5-38-08";
  3142. CommandDeleteReading(undef, "$name .*");
  3143. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3144. $updateState = 0;
  3145. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3146. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3147. } elsif ($cmd eq "basic") {
  3148. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 51.2)) {
  3149. #$updateState = 0;
  3150. $data = sprintf "%02X00%02X08", $gwCmdID, $a[1] * 5;
  3151. shift(@a);
  3152. } else {
  3153. return "Usage: $cmd parameter is not numeric or out of range.";
  3154. }
  3155. } else {
  3156. return "Unknown argument $cmd, choose one of teach:noArg basic";
  3157. }
  3158. } elsif ($gwCmd eq "controlVar") {
  3159. $gwCmdID = 5;
  3160. my $controlVar = ReadingsVal($name, "controlVar", 0);
  3161. if($cmd eq "teach") {
  3162. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3163. $data = "E047FF80";
  3164. $attr{$name}{eep} = "A5-38-08";
  3165. CommandDeleteReading(undef, "$name .*");
  3166. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3167. $updateState = 0;
  3168. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3169. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3170. } elsif ($cmd eq "presence") {
  3171. if ($a[1] eq "standby") {
  3172. $setCmd = 0x0A;
  3173. } elsif ($a[1] eq "absent") {
  3174. $setCmd = 9;
  3175. } elsif ($a[1] eq "present") {
  3176. $setCmd = 8;
  3177. } else {
  3178. return "Usage: $cmd parameter unknown.";
  3179. }
  3180. shift(@a);
  3181. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3182. } elsif ($cmd eq "energyHoldOff") {
  3183. if ($a[1] eq "normal") {
  3184. $setCmd = 8;
  3185. } elsif ($a[1] eq "holdoff") {
  3186. $setCmd = 0x0C;
  3187. } else {
  3188. return "Usage: $cmd parameter unknown.";
  3189. }
  3190. shift(@a);
  3191. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3192. } elsif ($cmd eq "controllerMode") {
  3193. if ($a[1] eq "auto") {
  3194. $setCmd = 8;
  3195. } elsif ($a[1] eq "heating") {
  3196. $setCmd = 0x28;
  3197. } elsif ($a[1] eq "cooling") {
  3198. $setCmd = 0x48;
  3199. } elsif ($a[1] eq "off" || $a[1] eq "BI") {
  3200. $setCmd = 0x68;
  3201. } else {
  3202. return "Usage: $cmd parameter unknown.";
  3203. }
  3204. shift(@a);
  3205. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3206. } elsif ($cmd eq "controllerState") {
  3207. if ($a[1] eq "auto") {
  3208. $setCmd = 8;
  3209. } elsif ($a[1] eq "override") {
  3210. $setCmd = 0x18;
  3211. if (defined $a[2] && ($a[2] =~ m/^[+-]?\d+$/) && ($a[2] >= 0) && ($a[2] <= 100) ) {
  3212. $controlVar = $a[2] * 255;
  3213. shift(@a);
  3214. } else {
  3215. return "Usage: Control Variable Override is not numeric or out of range.";
  3216. }
  3217. } else {
  3218. return "Usage: $cmd parameter unknown.";
  3219. }
  3220. shift(@a);
  3221. #$updateState = 0;
  3222. $data = sprintf "%02X00%02X%02X", $gwCmdID, $controlVar, $setCmd;
  3223. } else {
  3224. return "Unknown argument, choose one of teach:noArg presence:absent,present,standby energyHoldOff:holdoff,normal controllerMode:cooling,heating,off controllerState:auto,override";
  3225. }
  3226. } elsif ($gwCmd eq "fanStage") {
  3227. $gwCmdID = 6;
  3228. if($cmd eq "teach") {
  3229. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3230. $data = "E047FF80";
  3231. $attr{$name}{eep} = "A5-38-08";
  3232. CommandDeleteReading(undef, "$name .*");
  3233. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3234. $updateState = 0;
  3235. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3236. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3237. } elsif ($cmd eq "stage") {
  3238. if ($a[1] eq "auto") {
  3239. #$updateState = 0;
  3240. $data = sprintf "%02X00%02X08", $gwCmdID, 255;
  3241. } elsif ($a[1] && $a[1] =~ m/^[0-3]$/) {
  3242. #$updateState = 0;
  3243. $data = sprintf "%02X00%02X08", $gwCmdID, $a[1];
  3244. } else {
  3245. return "Usage: $cmd parameter is not numeric or out of range"
  3246. }
  3247. shift(@a);
  3248. } else {
  3249. return "Unknown argument, choose one of teach:noArg stage:auto,0,1,2,3";
  3250. }
  3251. } elsif ($gwCmd eq "blindCmd") {
  3252. $gwCmdID = 7;
  3253. my %blindFunc = (
  3254. "status" => 0,
  3255. "stop" => 1,
  3256. "opens" => 2,
  3257. "closes" => 3,
  3258. "position" => 4,
  3259. "up" => 5,
  3260. "down" => 6,
  3261. "runtimeSet" => 7,
  3262. "angleSet" => 8,
  3263. "positionMinMax" => 9,
  3264. "angleMinMax" => 10,
  3265. "positionLogic" => 11,
  3266. "teach" => 255,
  3267. );
  3268. my @blindFunc = (
  3269. "position:slider,0,1,100",
  3270. "opens:noArg",
  3271. "closes:noArg",
  3272. "up",
  3273. "down",
  3274. "stop:noArg",
  3275. "status:noArg",
  3276. "runtimeSet",
  3277. "angleSet",
  3278. "positionMinMax",
  3279. "angleMinMax",
  3280. "positionLogic:normal,inverse",
  3281. "teach:noArg",
  3282. );
  3283. my $blindFuncID;
  3284. if (defined $blindFunc {$cmd}) {
  3285. $blindFuncID = $blindFunc {$cmd};
  3286. } elsif ($cmd =~ m/^\d+$/) {
  3287. # interpretive numeric value as position
  3288. unshift(@a, 'position');
  3289. $cmd = 'position';
  3290. $blindFuncID = 4;
  3291. } else {
  3292. return "Unknown Gateway Blind Central Function " . $cmd . ", choose one of ". join(" ", @blindFunc);
  3293. }
  3294. my $blindParam1 = 0;
  3295. my $blindParam2 = 0;
  3296. $setCmd = $blindFuncID << 4 | 8;
  3297. if($blindFuncID == 255) {
  3298. # teach-in EEP A5-38-08, Manufacturer "Multi user Manufacturer ID"
  3299. $gwCmdID = 0xE0;
  3300. $blindParam1 = 0x47;
  3301. $blindParam2 = 0xFF;
  3302. $setCmd = 0x80;
  3303. $attr{$name}{eep} = "A5-38-08";
  3304. CommandDeleteReading(undef, "$name .*");
  3305. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3306. $updateState = 0;
  3307. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3308. } elsif ($blindFuncID == 0) {
  3309. # status
  3310. $updateState = 0;
  3311. } elsif ($blindFuncID == 1) {
  3312. # stop
  3313. $updateState = 0;
  3314. } elsif ($blindFuncID == 2) {
  3315. # opens
  3316. $updateState = 0;
  3317. } elsif ($blindFuncID == 3) {
  3318. # closes
  3319. $updateState = 0;
  3320. } elsif ($blindFuncID == 4) {
  3321. # position
  3322. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  3323. $blindParam1 = $a[1];
  3324. shift(@a);
  3325. if (defined $a[1]) {
  3326. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= -180 && $a[1] <= 180) {
  3327. # set angle
  3328. $blindParam2 = abs($a[1]) / 2;
  3329. if ($a[1] < 0) {$blindParam2 |= 0x80;}
  3330. shift(@a);
  3331. } else {
  3332. return "Usage: $cmd variable is not numeric or out of range.";
  3333. }
  3334. } else {
  3335. # set angle defaults
  3336. my $positionLogic = ReadingsVal($name, 'positionLogic', 'normal');
  3337. my $angleMin = ReadingsVal($name, 'angleMin', -180);
  3338. my $angleMax = ReadingsVal($name, 'angleMax', 180);
  3339. if ($blindParam1 == 0) {
  3340. $blindParam2 = $positionLogic eq 'normal' ? $angleMax : $angleMin;
  3341. } elsif ($blindParam1 == 100) {
  3342. $blindParam2 = $positionLogic eq 'normal' ? $angleMin : $angleMax;
  3343. } else {
  3344. $blindParam2 = $angleMin + ($angleMax - $angleMin) / 2;
  3345. }
  3346. if ($blindParam2 < 0) {
  3347. $blindParam2 = abs($blindParam2) / 2;
  3348. $blindParam2 |= 0x80;
  3349. } else {
  3350. $blindParam2 = $blindParam2 / 2;
  3351. }
  3352. }
  3353. } else {
  3354. return "Usage: $cmd variable is not numeric or out of range.";
  3355. }
  3356. # angle und position value available
  3357. $setCmd |= 2;
  3358. $updateState = 0;
  3359. } elsif ($blindFuncID == 5 || $blindFuncID == 6) {
  3360. # up / down
  3361. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3362. $blindParam1 = $a[1];
  3363. if (defined $a[2] && $a[2] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[2] >= 0 && $a[2] <= 25.5) {
  3364. $blindParam2 = $a[2] * 10;
  3365. shift(@a);
  3366. } else {
  3367. return "Usage: $cmd variable is not numeric or out of range.";
  3368. }
  3369. shift(@a);
  3370. } else {
  3371. return "Usage: $cmd variable is not numeric or out of range.";
  3372. }
  3373. $updateState = 0;
  3374. } elsif ($blindFuncID == 7) {
  3375. # runtimeSet
  3376. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3377. $blindParam1 = $a[1];
  3378. if (defined $a[2] && $a[2] =~ m/^[+-]?\d+$/ && $a[2] >= 0 && $a[2] <= 255) {
  3379. $blindParam2 = $a[2];
  3380. shift(@a);
  3381. } else {
  3382. return "Usage: $cmd variable is not numeric or out of range.";
  3383. }
  3384. shift(@a);
  3385. } else {
  3386. return "Usage: $cmd variable is not numeric or out of range.";
  3387. }
  3388. readingsSingleUpdate($hash, "runTimeUp", $blindParam1, 1);
  3389. readingsSingleUpdate($hash, "runTimeDown", $blindParam2, 1);
  3390. $updateState = 0;
  3391. } elsif ($blindFuncID == 8) {
  3392. # angleSet
  3393. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+(\.\d+)?$/ && $a[1] >= 0 && $a[1] <= 25.5) {
  3394. $blindParam1 = $a[1] * 10;
  3395. ##
  3396. readingsSingleUpdate($hash, "angleTime", (sprintf "%0.1f", $a[1]), 1);
  3397. shift(@a);
  3398. } else {
  3399. return "Usage: $cmd variable is not numeric or out of range.";
  3400. }
  3401. $updateState = 0;
  3402. } elsif ($blindFuncID == 9) {
  3403. # positionMinMax
  3404. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  3405. $blindParam1 = $a[1];
  3406. if (defined $a[2] && $a[2] =~ m/^[+-]?\d+$/ && $a[2] >= 0 && $a[2] <= 100) {
  3407. $blindParam2 = $a[2];
  3408. shift(@a);
  3409. } else {
  3410. return "Usage: $cmd variable is not numeric or out of range.";
  3411. }
  3412. # angle und position value available
  3413. $setCmd |= 2;
  3414. shift(@a);
  3415. } else {
  3416. return "Usage: $cmd variable is not numeric or out of range.";
  3417. }
  3418. if ($blindParam1 > $blindParam2) {($blindParam1, $blindParam2) = ($blindParam2, $blindParam1);}
  3419. readingsSingleUpdate($hash, "positionMin", $blindParam1, 1);
  3420. readingsSingleUpdate($hash, "positionMax", $blindParam2, 1);
  3421. $updateState = 0;
  3422. } elsif ($blindFuncID == 10) {
  3423. # angleMinMax
  3424. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= -180 && $a[1] <= 180) {
  3425. if (!defined $a[2] || $a[2] !~ m/^[+-]?\d+$/ || $a[2] < -180 || $a[2] > 180) {
  3426. return "Usage: $cmd variable is not numeric or out of range.";
  3427. }
  3428. if ($a[1] > $a[2]) {($a[1], $a[2]) = ($a[2], $a[1]);}
  3429. $blindParam1 = abs($a[1]) / 2;
  3430. if ($a[1] < 0) {$blindParam1 |= 0x80;}
  3431. $blindParam2 = abs($a[2]) / 2;
  3432. if ($a[2] < 0) {$blindParam2 |= 0x80;}
  3433. # angle und position value available
  3434. $setCmd |= 2;
  3435. } else {
  3436. return "Usage: $cmd variable is not numeric or out of range.";
  3437. }
  3438. readingsSingleUpdate($hash, "angleMin", $a[1], 1);
  3439. readingsSingleUpdate($hash, "angleMax", $a[2], 1);
  3440. splice (@a, 0, 2);
  3441. shift(@a);
  3442. $updateState = 0;
  3443. } elsif ($blindFuncID == 11) {
  3444. # positionLogic
  3445. if ($a[1] eq "normal") {
  3446. $blindParam1 = 0;
  3447. } elsif ($a[1] eq "inverse") {
  3448. $blindParam1 = 1;
  3449. } else {
  3450. return "Usage: $cmd variable is unknown.";
  3451. }
  3452. readingsSingleUpdate($hash, "positionLogic", $a[1], 1);
  3453. shift(@a);
  3454. $updateState = 0;
  3455. } else {
  3456. }
  3457. $setCmd |= 4 if (AttrVal($name, "sendDevStatus", "no") eq "yes");
  3458. $setCmd |= 1 if (AttrVal($name, "serviceOn", "no") eq "yes");
  3459. $data = sprintf "%02X%02X%02X%02X", $gwCmdID, $blindParam1, $blindParam2, $setCmd;
  3460. } else {
  3461. return "Unknown Gateway command " . $cmd . ", choose one of ". $cmdList . join(" ", sort keys %EnO_gwCmd);
  3462. }
  3463. Log3 $name, 3, "EnOcean set $name $cmd";
  3464. } elsif ($st eq "energyManagement.01") {
  3465. # Energy Management, Demand Response (A5-37-01)
  3466. $rorg = "A5";
  3467. $updateState = 0;
  3468. my $drLevel = 15;
  3469. my $powerUsage = 100;
  3470. my $powerUsageLevel = 1;
  3471. my $powerUsageScale = 0;
  3472. my $randomStart = 0;
  3473. my $randomEnd = 0;
  3474. my $randomTime = rand(AttrVal($name, "demandRespRandomTime", 1));
  3475. my $setpoint = 255;
  3476. my $timeout = 0;
  3477. my $threshold = AttrVal($name, "demandRespThreshold", 8);
  3478. if($cmd eq "teach") {
  3479. # teach-in EEP A5-37-01, Manufacturer "Multi user Manufacturer ID"
  3480. $data = "DC0FFF80";
  3481. $attr{$name}{eep} = "A5-37-01";
  3482. CommandDeleteReading(undef, "$name .*");
  3483. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3484. $updateState = 0;
  3485. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3486. Log3 $name, 3, "EnOcean set $name $cmd";
  3487. } elsif ($cmd eq "level") {
  3488. return "Usage: $cmd 0...15 [max|rel [yes|no [yes|no [timeout/min]]]]"
  3489. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 15 );
  3490. $drLevel = $a[1];
  3491. $powerUsage = $a[1] / 15 * 100;
  3492. $powerUsageLevel = $drLevel >= $threshold ? 1 : 0;
  3493. $setpoint = $a[1] * 17;
  3494. shift(@a);
  3495. } elsif ($cmd eq "max") {
  3496. } elsif ($cmd eq "min") {
  3497. $drLevel = 0;
  3498. $powerUsage = 0;
  3499. $powerUsageLevel = 0;
  3500. $setpoint = 0;
  3501. } elsif ($cmd eq "power") {
  3502. return "Usage: $cmd 0...100 [max|rel [yes|no [yes|no [timeout/min]]]]"
  3503. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 100);
  3504. $drLevel = $a[1] / 100 * 15;
  3505. $powerUsage = $a[1];
  3506. $powerUsageLevel = $drLevel >= $threshold ? 1 : 0;
  3507. $setpoint = $a[1] * 2.55;
  3508. shift(@a);
  3509. } elsif ($cmd eq "setpoint") {
  3510. return "Usage: $cmd 0...255 [max|rel [yes|no [yes|no [timeout/min]]]]"
  3511. if(@a < 2 || $a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 255 );
  3512. $drLevel = $a[1] / 255 * 15 ;
  3513. $powerUsage = $a[1] / 255 * 100;
  3514. $powerUsageLevel = $drLevel >= $threshold ? 1 : 0;
  3515. $setpoint = $a[1];
  3516. shift(@a);
  3517. } else {
  3518. 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"
  3519. }
  3520. if ($cmd ne "teach") {
  3521. if (@a > 1) {
  3522. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]" if($a[1] !~ m/^max|rel$/);
  3523. $powerUsageScale = $a[1] eq "rel" ? 0x80 : 0;
  3524. shift(@a);
  3525. }
  3526. if (@a > 1) {
  3527. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]" if($a[1] !~ m/^yes|no$/);
  3528. $randomStart = $a[1] eq "yes" ? 4 : 0;
  3529. shift(@a);
  3530. }
  3531. if (@a > 1) {
  3532. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]" if($a[1] !~ m/^yes|no$/);
  3533. $randomEnd = $a[1] eq "yes" ? 2 : 0;
  3534. shift(@a);
  3535. }
  3536. if (@a > 1) {
  3537. return "Usage: $cmd [<cmdValue>] [max|rel [yes|no [yes|no [timeout/min]]]]"
  3538. if($a[1] !~ m/^\d+$/ || $a[1] < 0 || $a[1] > 3825);
  3539. $timeout = int($a[1] / 15);
  3540. shift(@a);
  3541. }
  3542. $data = sprintf "%02X%02X%02X%02X", $setpoint, $powerUsageScale | $powerUsage, $timeout,
  3543. $drLevel << 4 | $randomStart | $randomEnd | $powerUsageLevel | 8;
  3544. my @db = ($drLevel << 4 | $randomStart | $randomEnd | $powerUsageLevel | 8,
  3545. $timeout, $powerUsageScale | $powerUsage, $setpoint);
  3546. EnOcean_energyManagement_01Parse($hash, @db);
  3547. }
  3548. Log3 $name, 3, "EnOcean set $name $cmd";
  3549. } elsif ($st eq "lightCtrl.01") {
  3550. # Central Command, Extended Lighting-Control (EEP A5-38-09)
  3551. $rorg = "A5";
  3552. my %ctrlFunc = (
  3553. "off" => 1,
  3554. "on" => 2,
  3555. "dimup" => 3,
  3556. "dimdown" => 4,
  3557. "stop" => 5,
  3558. "dim" => 6,
  3559. "rgb" => 7,
  3560. "scene" => 8,
  3561. "dimMinMax" => 9,
  3562. "lampOpHours" => 10,
  3563. "block" => 11,
  3564. "meteringValue" => 12,
  3565. "teach" => 255,
  3566. );
  3567. my $ctrlFuncID;
  3568. if (exists $ctrlFunc{$cmd}) {
  3569. $ctrlFuncID = $ctrlFunc{$cmd};
  3570. } elsif ($cmd =~ m/^\d+$/) {
  3571. # interpretive numeric value as dimming
  3572. unshift(@a, 'dim');
  3573. $cmd = 'dim';
  3574. $ctrlFuncID = 6;
  3575. } else {
  3576. $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";
  3577. return SetExtensions ($hash, $cmdList, $name, @a);
  3578. }
  3579. my ($ctrlParam1, $ctrlParam2, $ctrlParam3) = (0, 0, 0);
  3580. my $setCmd = $ctrlFuncID << 4 | 8;
  3581. if($ctrlFuncID == 255) {
  3582. # teach-in EEP A5-38-09, Manufacturer "Multi user Manufacturer ID"
  3583. $ctrlParam1 = 0xE1;
  3584. $ctrlParam2 = 0xC7;
  3585. $ctrlParam3 = 0xFF;
  3586. $setCmd = 0x80;
  3587. $attr{$name}{eep} = "A5-38-09";
  3588. CommandDeleteReading(undef, "$name .*");
  3589. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3590. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3591. $updateState = 0;
  3592. } elsif ($ctrlFuncID == 1) {
  3593. # off
  3594. CommandDeleteReading(undef, "$name scene");
  3595. #####
  3596. SetExtensionsCancel($hash);
  3597. $updateState = 0;
  3598. } elsif ($ctrlFuncID == 2) {
  3599. # on
  3600. CommandDeleteReading(undef, "$name scene");
  3601. #####
  3602. SetExtensionsCancel($hash);
  3603. $updateState = 0;
  3604. } elsif ($ctrlFuncID == 3 || $ctrlFuncID == 4) {
  3605. # dimup / dimdown
  3606. my $rampTime = $a[1];
  3607. if (defined $a[1]) {
  3608. if ($a[1] =~ m/^\d+?$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3609. shift(@a);
  3610. } else {
  3611. return "Usage: $cmd ramping time value is not numeric or out of range.";
  3612. }
  3613. } else {
  3614. $rampTime = AttrVal($name, "rampTime", 1);
  3615. }
  3616. $ctrlParam3 = $rampTime & 0xFF;
  3617. $ctrlParam2 = ($rampTime & 0xFF00) >> 8;
  3618. readingsSingleUpdate($hash, "rampTime", $rampTime, 1);
  3619. CommandDeleteReading(undef, "$name scene");
  3620. #####
  3621. SetExtensionsCancel($hash);
  3622. $updateState = 0;
  3623. } elsif ($ctrlFuncID == 5) {
  3624. # stop
  3625. CommandDeleteReading(undef, "$name scene");
  3626. #####
  3627. SetExtensionsCancel($hash);
  3628. $updateState = 0;
  3629. } elsif ($ctrlFuncID == 6) {
  3630. # dim
  3631. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3632. $ctrlParam1 = $a[1];
  3633. shift(@a);
  3634. } else {
  3635. return "Usage: $cmd dimming value is not numeric or out of range.";
  3636. }
  3637. my $rampTime = $a[1];
  3638. if (defined $a[1]) {
  3639. if ($a[1] =~ m/^\d+?$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3640. shift(@a);
  3641. } else {
  3642. return "Usage: $cmd ramping time value is not numeric or out of range.";
  3643. }
  3644. } else {
  3645. $rampTime = AttrVal($name, "rampTime", 1);
  3646. }
  3647. $ctrlParam3 = $rampTime & 0xFF;
  3648. $ctrlParam2 = ($rampTime & 0xFF00) >> 8;
  3649. CommandDeleteReading(undef, "$name scene");
  3650. readingsSingleUpdate($hash, "rampTime", $rampTime, 1);
  3651. #####
  3652. SetExtensionsCancel($hash);
  3653. $updateState = 0;
  3654. } elsif ($ctrlFuncID == 7) {
  3655. # RGB
  3656. if (@a > 1) {
  3657. if ($a[1] =~ m/^[\dA-Fa-f]{6}$/) {
  3658. # red
  3659. $ctrlParam1 = hex substr($a[1], 0, 2);
  3660. # green
  3661. $ctrlParam2 = hex substr($a[1], 2, 2);
  3662. # blue
  3663. $ctrlParam3 = hex substr($a[1], 4, 2);
  3664. readingsBeginUpdate($hash);
  3665. readingsBulkUpdate($hash, "red", $ctrlParam1);
  3666. readingsBulkUpdate($hash, "green", $ctrlParam2);
  3667. readingsBulkUpdate($hash, "blue", $ctrlParam3);
  3668. readingsBulkUpdate($hash, "rgb", uc($a[1]));
  3669. readingsEndUpdate($hash, 0);
  3670. shift(@a);
  3671. } else {
  3672. return "Usage: $cmd value is not hexadecimal or out of range.";
  3673. }
  3674. } else {
  3675. return "Usage: $cmd values are missing";
  3676. }
  3677. $updateState = 0;
  3678. } elsif ($ctrlFuncID == 8) {
  3679. # scene
  3680. if (@a > 2) {
  3681. if ($a[2] =~ m/^\d+?$/ && $a[2] >= 0 && $a[2] <= 15) {
  3682. $ctrlParam3 = $a[2];
  3683. } else {
  3684. return "Usage: $cmd number is not numeric or out of range.";
  3685. }
  3686. if ($a[1] eq "drive") {
  3687. readingsSingleUpdate($hash, "scene", $ctrlParam3, 1);
  3688. splice(@a, 0, 2);
  3689. } elsif ($a[1] eq "store") {
  3690. $ctrlParam3 |= 0x80;
  3691. splice(@a, 0, 2);
  3692. } else {
  3693. return "Usage: $cmd parameter is wrong.";
  3694. }
  3695. } else {
  3696. return "Usage: $cmd values are missing";
  3697. }
  3698. $updateState = 0;
  3699. } elsif ($ctrlFuncID == 9) {
  3700. # dimMinMax
  3701. if (@a > 2) {
  3702. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3703. # dimming limit min
  3704. $ctrlParam1 = $a[1];
  3705. shift(@a);
  3706. } else {
  3707. return "Usage: $cmd value is not numeric or out of range.";
  3708. }
  3709. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3710. # dimming limit max
  3711. $ctrlParam2 = $a[1];
  3712. shift(@a);
  3713. } else {
  3714. return "Usage: $cmd value is not numeric or out of range.";
  3715. }
  3716. readingsBeginUpdate($hash);
  3717. readingsBulkUpdate($hash, "dimMin", $ctrlParam1);
  3718. readingsBulkUpdate($hash, "dimMax", $ctrlParam2);
  3719. readingsEndUpdate($hash, 1);
  3720. } else {
  3721. return "Usage: $cmd values are missing";
  3722. }
  3723. $updateState = 0;
  3724. } elsif ($ctrlFuncID == 10) {
  3725. # set operating hours of the lamp
  3726. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3727. $ctrlParam2 = $a[1] & 0xFF;
  3728. $ctrlParam1 = ($a[1] & 0xFF00) >> 8;
  3729. shift(@a);
  3730. } else {
  3731. return "Usage: $cmd variable is not numeric or out of range.";
  3732. }
  3733. $updateState = 0;
  3734. } elsif ($ctrlFuncID == 11) {
  3735. # block
  3736. if (!defined $a[1]) {
  3737. return "Usage: $cmd values are missing";
  3738. } elsif ($a[1] eq "unlock") {
  3739. $ctrlParam3 = 0;
  3740. } elsif ($a[1] eq "on") {
  3741. $ctrlParam3 = 1;
  3742. } elsif ($a[1] eq "off") {
  3743. $ctrlParam3 = 2;
  3744. } elsif ($a[1] eq "local") {
  3745. $ctrlParam3 = 3;
  3746. } else {
  3747. return "Usage: $cmd variable is unknown.";
  3748. }
  3749. readingsSingleUpdate($hash, "block", $a[1], 1);
  3750. shift(@a);
  3751. $updateState = 0;
  3752. } elsif ($ctrlFuncID == 12) {
  3753. # meteringValues
  3754. if (@a > 2) {
  3755. my %unitEnum = (
  3756. "mW" => 0,
  3757. "W" => 1,
  3758. "kW" => 2,
  3759. "MW" => 3,
  3760. "Wh" => 4,
  3761. "kWh" => 5,
  3762. "MWh" => 6,
  3763. "GWh" => 7,
  3764. "mA" => 8,
  3765. "A" => 9,
  3766. "mV" => 10,
  3767. "V" => 11,
  3768. );
  3769. if (exists $unitEnum{$a[2]}) {
  3770. $ctrlParam3 = $unitEnum{$a[2]};
  3771. } else {
  3772. return "Unknown metering value choose one of " . join(" ", sort keys %unitEnum);
  3773. }
  3774. if ($ctrlParam3 == 9 || $ctrlParam3 == 11) {
  3775. if ($a[1] =~ m/^\d+(\.\d+)?$/ && $a[1] >= 0 && $a[1] <= 6553.5) {
  3776. $ctrlParam2 = int($a[1] * 10) & 0xFF;
  3777. $ctrlParam1 = (int($a[1] * 10) & 0xFF00) >> 8;
  3778. } else {
  3779. return "Usage: $cmd value is not numeric or out of range.";
  3780. }
  3781. } else {
  3782. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 65535) {
  3783. $ctrlParam2 = $a[1] & 0xFF;
  3784. $ctrlParam1 = ($a[1] & 0xFF00) >> 8;
  3785. } else {
  3786. return "Usage: $cmd value is not numeric or out of range.";
  3787. }
  3788. }
  3789. splice(@a, 0, 2);
  3790. } else {
  3791. return "Usage: $cmd values are missing";
  3792. }
  3793. $updateState = 0;
  3794. }
  3795. $setCmd |= 4 if (AttrVal($name, "sendDevStatus", "yes") eq "no");
  3796. $setCmd |= 1 if (AttrVal($name, "serviceOn", "no") eq "yes");
  3797. $data = sprintf "%02X%02X%02X%02X", $ctrlParam1, $ctrlParam2, $ctrlParam3, $setCmd;
  3798. Log3 $name, 3, "EnOcean set $name $cmd";
  3799. } elsif ($st eq "radioLinkTest") {
  3800. # Radio Link Test (A5-3F-00)
  3801. $rorg = "A5";
  3802. $updateState = 3;
  3803. if($cmd =~ m/^standby|stop$/) {
  3804. @{$hash->{helper}{rlt}{param}} = ($cmd, $hash, undef, $subDef, 'master', 0);
  3805. EnOcean_RLT($hash->{helper}{rlt}{param});
  3806. } else {
  3807. return "Unknown argument " . $cmd . ", choose one of " . $cmdList . "standby:noArg stop:noArg"
  3808. }
  3809. Log3 $name, 3, "EnOcean set $name $cmd";
  3810. } elsif ($st eq "manufProfile") {
  3811. if ($manufID eq "00D") {
  3812. # Eltako Shutter
  3813. my $angleMax = AttrVal($name, "angleMax", 90);
  3814. my $angleMin = AttrVal($name, "angleMin", -90);
  3815. my $anglePos = ReadingsVal($name, "anglePos", undef);
  3816. my $anglePosStart;
  3817. my $angleTime = AttrVal($name, "angleTime", 0);
  3818. my $position = ReadingsVal($name, "position", undef);
  3819. my $positionStart;
  3820. my $setCmd = 8;
  3821. my $settingAccuracy = 1;
  3822. if (AttrVal($name, 'settingAccuracy', 'low') eq 'high') {
  3823. $setCmd = 0x0A;
  3824. $settingAccuracy = 10;
  3825. }
  3826. if ($cmd eq "?" || $cmd eq "stop") {
  3827. } else {
  3828. # check actual shutter position
  3829. my $actualState = ReadingsVal($name, "state", undef);
  3830. if (defined $actualState) {
  3831. if ($actualState eq "open") {
  3832. $position = 0;
  3833. $anglePos = 0;
  3834. } elsif ($actualState eq "closed") {
  3835. $position = 100;
  3836. $anglePos = $angleMax;
  3837. }
  3838. }
  3839. $anglePosStart = $anglePos;
  3840. $positionStart = $position;
  3841. readingsSingleUpdate($hash, ".anglePosStart", $anglePosStart, 0);
  3842. readingsSingleUpdate($hash, ".positionStart", $positionStart, 0);
  3843. }
  3844. $rorg = "A5";
  3845. my $shutTime = AttrVal($name, "shutTime", 255);
  3846. my $shutTimeCloses = AttrVal($name, "shutTimeCloses", $shutTime);
  3847. $shutTimeCloses = $shutTime if ($shutTimeCloses < $shutTime);
  3848. my $shutCmd = 0;
  3849. $angleMax = 90 if ($angleMax !~ m/^[+-]?\d+$/);
  3850. $angleMax = 180 if ($angleMax > 180);
  3851. $angleMax = -180 if ($angleMax < -180);
  3852. $angleMin = -90 if ($angleMin !~ m/^[+-]?\d+$/);
  3853. $angleMin = 180 if ($angleMin > 180);
  3854. $angleMin = -180 if ($angleMin < -180);
  3855. ($angleMax, $angleMin) = ($angleMin, $angleMax) if ($angleMin > $angleMax);
  3856. $angleMax ++ if ($angleMin == $angleMax);
  3857. $angleTime = 6 if ($angleTime !~ m/^[+-]?\d+$/);
  3858. $angleTime = 6 if ($angleTime > 6);
  3859. $angleTime = 0 if ($angleTime < 0);
  3860. $shutTime = 255 if ($shutTime !~ m/^[+-]?\d+$/);
  3861. $shutTime = 255 if ($shutTime > 255);
  3862. $shutTime = 1 if ($shutTime < 1);
  3863. if ($cmd =~ m/^\d+$/) {
  3864. # interpretive numeric value as position
  3865. unshift(@a, 'position');
  3866. $cmd = 'position';
  3867. }
  3868. if ($cmd eq "teach") {
  3869. # teach-in EEP A5-3F-7F, Manufacturer "Eltako"
  3870. $data = "FFF80D80";
  3871. $attr{$name}{eep} = "A5-3F-7F";
  3872. CommandDeleteReading(undef, "$name .*");
  3873. readingsSingleUpdate($hash, "teach", "4BS teach-in sent", 1);
  3874. $updateState = 0;
  3875. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "confirm");
  3876. EnOcean_setTeachConfirmWaitHash(undef, $hash);
  3877. } elsif ($cmd eq "stop") {
  3878. # stop
  3879. # delete readings, as they are undefined
  3880. CommandDeleteReading(undef, "$name anglePos");
  3881. CommandDeleteReading(undef, "$name position");
  3882. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  3883. readingsSingleUpdate($hash, "state", "stop", 1);
  3884. $shutCmd = 0;
  3885. } elsif ($cmd eq "opens") {
  3886. # opens >> B0
  3887. $anglePos = 0;
  3888. $position = 0;
  3889. readingsSingleUpdate($hash, "anglePos", $anglePos, 1);
  3890. readingsSingleUpdate($hash, "position", $position, 1);
  3891. readingsSingleUpdate($hash, "endPosition", "open", 1);
  3892. $cmd = "open";
  3893. $shutTime = $shutTimeCloses;
  3894. $shutCmd = 1;
  3895. #$updateState = 0;
  3896. } elsif ($cmd eq "closes") {
  3897. # closes >> BI
  3898. $anglePos = $angleMax;
  3899. $position = 100;
  3900. readingsSingleUpdate($hash, "anglePos", $anglePos, 1);
  3901. readingsSingleUpdate($hash, "position", $position, 1);
  3902. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  3903. $cmd = "closed";
  3904. $shutTime = $shutTimeCloses;
  3905. $shutCmd = 2;
  3906. #$updateState = 0;
  3907. } elsif ($cmd eq "up") {
  3908. # up
  3909. if (defined $a[1]) {
  3910. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3911. $position = $positionStart - $a[1] / $shutTime * 100;
  3912. if ($angleTime) {
  3913. $anglePos = $anglePosStart - ($angleMax - $angleMin) * $a[1] / $angleTime;
  3914. if ($anglePos < $angleMin) {
  3915. $anglePos = $angleMin;
  3916. }
  3917. } else {
  3918. $anglePos = $angleMin;
  3919. }
  3920. if ($position <= 0) {
  3921. $anglePos = 0;
  3922. $position = 0;
  3923. readingsSingleUpdate($hash, "endPosition", "open", 1);
  3924. $cmd = "open";
  3925. } else {
  3926. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  3927. $cmd = "not_reached";
  3928. }
  3929. $shutTime = $a[1];
  3930. shift(@a);
  3931. } else {
  3932. return "Usage: $a[1] is not numeric or out of range";
  3933. }
  3934. } else {
  3935. $anglePos = 0;
  3936. $position = 0;
  3937. readingsSingleUpdate($hash, "endPosition", "open", 1);
  3938. $cmd = "open";
  3939. }
  3940. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  3941. readingsSingleUpdate($hash, "position", sprintf("%d", $position), 1);
  3942. $shutCmd = 1;
  3943. } elsif ($cmd eq "down") {
  3944. # down
  3945. if (defined $a[1]) {
  3946. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 255) {
  3947. $position = $positionStart + $a[1] / $shutTime * 100;
  3948. if ($angleTime) {
  3949. $anglePos = $anglePosStart + ($angleMax - $angleMin) * $a[1] / $angleTime;
  3950. if ($anglePos > $angleMax) {
  3951. $anglePos = $angleMax;
  3952. }
  3953. } else {
  3954. $anglePos = $angleMax;
  3955. }
  3956. if($position >= 100) {
  3957. $anglePos = $angleMax;
  3958. $position = 100;
  3959. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  3960. $cmd = "closed";
  3961. } else {
  3962. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  3963. $cmd = "not_reached";
  3964. }
  3965. $shutTime = $a[1];
  3966. shift(@a);
  3967. } else {
  3968. return "Usage: $a[1] is not numeric or out of range";
  3969. }
  3970. } else {
  3971. $anglePos = $angleMax;
  3972. $position = 100;
  3973. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  3974. $cmd = "closed";
  3975. }
  3976. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  3977. readingsSingleUpdate($hash, "position", sprintf("%d", $position), 1);
  3978. $shutCmd = 2;
  3979. } elsif ($cmd eq "position") {
  3980. if (!defined $positionStart) {
  3981. return "Position unknown, please first opens the blinds completely."
  3982. } elsif ($angleTime > 0 && !defined $anglePosStart){
  3983. return "Slats angle position unknown, please first opens the blinds completely."
  3984. } else {
  3985. my $shutTimeSet = $shutTime;
  3986. if (defined $a[2]) {
  3987. if ($a[2] =~ m/^[+-]?\d+$/ && $a[2] >= $angleMin && $a[2] <= $angleMax) {
  3988. $anglePos = $a[2];
  3989. } else {
  3990. return "Usage: $a[1] $a[2] is not numeric or out of range";
  3991. }
  3992. splice(@a,2,1);
  3993. } else {
  3994. $anglePos = $angleMax;
  3995. }
  3996. if ($positionStart <= $angleTime * $angleMax / ($angleMax - $angleMin) / $shutTimeSet * 100) {
  3997. $anglePosStart = $angleMax;
  3998. }
  3999. if (defined $a[1] && $a[1] =~ m/^[+-]?\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  4000. if ($positionStart < $a[1]) {
  4001. # down
  4002. $angleTime = $angleTime * ($angleMax - $anglePos) / ($angleMax - $angleMin);
  4003. $shutTime = $shutTime * ($a[1] - $positionStart) / 100 + $angleTime;
  4004. # round up
  4005. $angleTime = int($angleTime) + 1 if ($settingAccuracy == 1 && $angleTime > int($angleTime));
  4006. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4007. $position = $a[1] + $angleTime / $shutTimeSet * 100;
  4008. if ($position >= 100) {
  4009. $position = 100;
  4010. }
  4011. $shutCmd = 2;
  4012. if ($angleTime) {
  4013. my @timerCmd = ($name, "up", $angleTime);
  4014. my %par = (hash => $hash, timerCmd => \@timerCmd);
  4015. InternalTimer(gettimeofday() + $shutTime + 1, "EnOcean_TimerSet", \%par, 0);
  4016. }
  4017. } elsif ($positionStart > $a[1]) {
  4018. # up
  4019. $angleTime = $angleTime * ($anglePos - $angleMin) /($angleMax - $angleMin);
  4020. $shutTime = $shutTime * ($positionStart - $a[1]) / 100 + $angleTime;
  4021. # round up
  4022. $angleTime = int($angleTime) + 1 if ($settingAccuracy == 1 && $angleTime > int($angleTime));
  4023. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4024. $position = $a[1] - $angleTime / $shutTimeSet * 100;
  4025. if ($position <= 0) {
  4026. $position = 0;
  4027. $anglePos = 0;
  4028. }
  4029. $shutCmd = 1;
  4030. if ($angleTime && $a[1] > 0) {
  4031. my @timerCmd = ($name, "down", $angleTime);
  4032. my %par = (hash => $hash, timerCmd => \@timerCmd);
  4033. InternalTimer(gettimeofday() + $shutTime + 1, "EnOcean_TimerSet", \%par, 0);
  4034. }
  4035. } else {
  4036. if ($anglePosStart > $anglePos) {
  4037. # up >> reduce slats angle
  4038. $shutTime = $angleTime * ($anglePosStart - $anglePos)/($angleMax - $angleMin);
  4039. # round up
  4040. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4041. $shutCmd = 1;
  4042. } elsif ($anglePosStart < $anglePos) {
  4043. # down >> enlarge slats angle
  4044. $shutTime = $angleTime * ($anglePos - $anglePosStart) /($angleMax - $angleMin);
  4045. # round up
  4046. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4047. $shutCmd = 2;
  4048. } else {
  4049. # position and slats angle ok
  4050. $data = '00000008';
  4051. $shutCmd = 0;
  4052. $updateState = 3;
  4053. }
  4054. }
  4055. if ($position == 0) {
  4056. readingsSingleUpdate($hash, "endPosition", "open", 1);
  4057. $cmd = "open";
  4058. } elsif ($position == 100) {
  4059. readingsSingleUpdate($hash, "endPosition", "closed", 1);
  4060. $cmd = "closed";
  4061. } else {
  4062. readingsSingleUpdate($hash, "endPosition", "not_reached", 1);
  4063. $cmd = "not_reached";
  4064. }
  4065. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  4066. readingsSingleUpdate($hash, "position", sprintf("%d", $position), 1);
  4067. shift(@a);
  4068. } else {
  4069. return "Usage: $a[1] is not numeric or out of range";
  4070. }
  4071. }
  4072. } elsif ($cmd eq "anglePos") {
  4073. if (!defined $positionStart) {
  4074. return "Position unknown, please first opens the blinds completely."
  4075. } elsif ($angleTime > 0 && !defined $anglePosStart){
  4076. return "Slats angle position unknown, please first opens the blinds completely."
  4077. } else {
  4078. if (defined $a[1]) {
  4079. if ($a[1] =~ m/^[+-]?\d+$/ && $a[1] >= $angleMin && $a[1] <= $angleMax) {
  4080. $anglePos = $a[1];
  4081. shift(@a);
  4082. if ($anglePosStart > $anglePos) {
  4083. # up >> reduce slats angle
  4084. $shutTime = $angleTime * ($anglePosStart - $anglePos)/($angleMax - $angleMin);
  4085. # round up
  4086. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4087. $shutCmd = 1;
  4088. } elsif ($anglePosStart < $anglePos) {
  4089. # down >> enlarge slats angle
  4090. $shutTime = $angleTime * ($anglePos - $anglePosStart) /($angleMax - $angleMin);
  4091. # round up
  4092. $shutTime = int($shutTime) + 1 if ($settingAccuracy == 1 && $shutTime > int($shutTime));
  4093. $shutCmd = 2;
  4094. } else {
  4095. # slats angle ok
  4096. $data = '00000008';
  4097. $shutCmd = 0;
  4098. $updateState = 3;
  4099. }
  4100. readingsSingleUpdate($hash, "anglePos", sprintf("%d", $anglePos), 1);
  4101. } else {
  4102. return "Usage: $a[1] is not numeric or out of range";
  4103. }
  4104. } else {
  4105. return "Usage: $cmd values are missing";
  4106. }
  4107. }
  4108. } elsif ($cmd eq "local") {
  4109. if ($a[1]) {
  4110. return "Usage: $cmd [learn]" if ($a[1] ne "learn");
  4111. if ($a[1] eq "learn") {
  4112. $setCmd = $setCmd | 0x20;
  4113. }
  4114. shift(@a);
  4115. }
  4116. $updateState = 0;
  4117. $data = sprintf "%04X%02X%02X", int($shutTime * $settingAccuracy), $shutCmd, $setCmd;
  4118. } else {
  4119. 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"
  4120. }
  4121. if ($shutCmd || $cmd eq "stop") {
  4122. #$updateState = 0;
  4123. $data = sprintf "%04X%02X%02X", int($shutTime * $settingAccuracy), $shutCmd, $setCmd;
  4124. }
  4125. Log3 $name, 3, "EnOcean set $name $cmd";
  4126. }
  4127. } elsif ($st eq "actuator.01") {
  4128. # Electronic switches and dimmers with Energy Measurement and Local Control
  4129. # (D2-01-00 - D2-01-12)
  4130. $rorg = "D2";
  4131. #$updateState = 0;
  4132. my $cmdID;
  4133. my $channel;
  4134. my $dimValTimer = 0;
  4135. my $outputVal;
  4136. if ($cmd =~ m/^\d+$/) {
  4137. # interpretive numeric value as dimming
  4138. unshift(@a, 'dim');
  4139. $cmd = 'dim';
  4140. }
  4141. if ($cmd eq "on") {
  4142. shift(@a);
  4143. $cmdID = 1;
  4144. my $dimValueOn = AttrVal($name, "dimValueOn", 100);
  4145. if ($dimValueOn eq "stored") {
  4146. $outputVal = ReadingsVal($name, "dimValueStored", 100);
  4147. if ($outputVal < 1) {
  4148. $outputVal = 100;
  4149. readingsSingleUpdate ($hash, "dimValueStored", $outputVal, 1);
  4150. }
  4151. } elsif ($dimValueOn eq "last") {
  4152. $outputVal = ReadingsVal ($name, "dimValueLast", 100);
  4153. if ($outputVal < 1) { $outputVal = 100; }
  4154. } else {
  4155. if ($dimValueOn !~ m/^[+-]?\d+$/) {
  4156. $outputVal = 100;
  4157. } elsif ($dimValueOn > 100) {
  4158. $outputVal = 100;
  4159. } elsif ($dimValueOn < 1) {
  4160. $outputVal = 1;
  4161. } else {
  4162. $outputVal = $dimValueOn;
  4163. }
  4164. }
  4165. $channel = shift(@a);
  4166. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4167. if (!defined $channel || $channel eq "all") {
  4168. CommandDeleteReading(undef, "$name channel.*");
  4169. CommandDeleteReading(undef, "$name dim.*");
  4170. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4171. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4172. $channel = 30;
  4173. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4174. readingsSingleUpdate($hash, "channelInput", "on", 1);
  4175. readingsSingleUpdate($hash, "dimInput", $outputVal, 1);
  4176. $channel = 31;
  4177. } elsif ($channel + 0 >= 30) {
  4178. CommandDeleteReading(undef, "$name channel.*");
  4179. CommandDeleteReading(undef, "$name dim.*");
  4180. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4181. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4182. $channel = 30;
  4183. } elsif ($channel + 0 >= 0 && $channel + 0 <= 29) {
  4184. readingsSingleUpdate($hash, "channel" . $channel, "on", 1);
  4185. readingsSingleUpdate($hash, "dim" . $channel, $outputVal, 1);
  4186. } else {
  4187. return "$cmd $channel wrong, choose 0...29|all|input.";
  4188. }
  4189. #readingsSingleUpdate($hash, "state", "on", 1);
  4190. $data = sprintf "%02X%02X%02X", $cmdID, $dimValTimer << 5 | $channel, $outputVal;
  4191. } elsif ($cmd eq "off") {
  4192. shift(@a);
  4193. $cmdID = 1;
  4194. $outputVal = 0;
  4195. $channel = shift(@a);
  4196. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4197. if (!defined $channel || $channel eq "all") {
  4198. CommandDeleteReading(undef, "$name channel.*");
  4199. CommandDeleteReading(undef, "$name dim.*");
  4200. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4201. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4202. $channel = 30;
  4203. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4204. readingsSingleUpdate($hash, "channelInput", "off", 1);
  4205. readingsSingleUpdate($hash, "dimInput", $outputVal, 1);
  4206. $channel = 31;
  4207. } elsif ($channel + 0 >= 30) {
  4208. CommandDeleteReading(undef, "$name channel.*");
  4209. CommandDeleteReading(undef, "$name dim.*");
  4210. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4211. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4212. $channel = 30;
  4213. } elsif ($channel >= 0 && $channel <= 29) {
  4214. readingsSingleUpdate($hash, "channel" . $channel, "off", 1);
  4215. readingsSingleUpdate($hash, "dim" . $channel, $outputVal, 1);
  4216. } else {
  4217. return "$cmd $channel wrong, choose 0...39|all|input.";
  4218. }
  4219. #readingsSingleUpdate($hash, "state", "off", 1);
  4220. $data = sprintf "%02X%02X%02X", $cmdID, $dimValTimer << 5 | $channel, $outputVal;
  4221. } elsif ($cmd eq "dim") {
  4222. shift(@a);
  4223. $cmdID = 1;
  4224. $outputVal = shift(@a);
  4225. if (!defined $outputVal || $outputVal !~ m/^[+-]?\d+$/ || $outputVal < 0 || $outputVal > 100) {
  4226. return "Usage: $cmd variable is not numeric or out of range.";
  4227. }
  4228. $channel = shift(@a);
  4229. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4230. if (!defined $channel) {
  4231. CommandDeleteReading(undef, "$name channel.*");
  4232. CommandDeleteReading(undef, "$name dim.*");
  4233. if ($outputVal == 0) {
  4234. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4235. } else {
  4236. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4237. }
  4238. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4239. $channel = 30;
  4240. } else {
  4241. if ($channel eq "all") {
  4242. CommandDeleteReading(undef, "$name channel.*");
  4243. CommandDeleteReading(undef, "$name dim.*");
  4244. if ($outputVal == 0) {
  4245. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4246. } else {
  4247. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4248. }
  4249. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4250. $channel = 30;
  4251. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4252. if ($outputVal == 0) {
  4253. readingsSingleUpdate($hash, "channelInput", "off", 1);
  4254. } else {
  4255. readingsSingleUpdate($hash, "channelInput", "on", 1);
  4256. }
  4257. readingsSingleUpdate($hash, "dimInput", $outputVal, 1);
  4258. $channel = 31;
  4259. } elsif ($channel + 0 >= 30) {
  4260. CommandDeleteReading(undef, "$name channel.*");
  4261. CommandDeleteReading(undef, "$name dim.*");
  4262. if ($outputVal == 0) {
  4263. readingsSingleUpdate($hash, "channelAll", "off", 1);
  4264. } else {
  4265. readingsSingleUpdate($hash, "channelAll", "on", 1);
  4266. }
  4267. readingsSingleUpdate($hash, "dim", $outputVal, 1);
  4268. $channel = 30;
  4269. } elsif ($channel >= 0 && $channel <= 29) {
  4270. if ($outputVal == 0) {
  4271. readingsSingleUpdate($hash, "channel" . $channel, "off", 1);
  4272. } else {
  4273. readingsSingleUpdate($hash, "channel" . $channel, "on", 1);
  4274. }
  4275. readingsSingleUpdate($hash, "dim" . $channel, $outputVal, 1);
  4276. } else {
  4277. return "Usage: $cmd $channel wrong, choose 0...39|all|input.";
  4278. }
  4279. $dimValTimer = shift(@a);
  4280. if (defined $dimValTimer) {
  4281. if ($dimValTimer eq "switch") {
  4282. $dimValTimer = 0;
  4283. } elsif ($dimValTimer eq "stop") {
  4284. $dimValTimer = 4;
  4285. } elsif ($dimValTimer =~ m/^[1-3]$/) {
  4286. } else {
  4287. return "Usage: $cmd <channel> $dimValTimer wrong, choose 1..3|switch|stop.";
  4288. }
  4289. } else {
  4290. $dimValTimer = 0;
  4291. }
  4292. }
  4293. if ($outputVal == 0) {
  4294. $cmd = "off";
  4295. #readingsSingleUpdate($hash, "state", "off", 1);
  4296. } else {
  4297. $cmd = "on";
  4298. #readingsSingleUpdate($hash, "state", "on", 1);
  4299. }
  4300. $data = sprintf "%02X%02X%02X", $cmdID, $dimValTimer << 5 | $channel, $outputVal;
  4301. } elsif ($cmd eq "local") {
  4302. shift(@a);
  4303. $updateState = 0;
  4304. $cmdID = 2;
  4305. # same configuration for all channels
  4306. $channel = 30;
  4307. my $dayNight = ReadingsVal($name, "dayNight", "day");
  4308. my $dayNightCmd = ($dayNight eq "night")? 1:0;
  4309. my $defaultState = ReadingsVal($name, "defaultState", "off");
  4310. my $defaultStateCmd;
  4311. if ($defaultState eq "off") {
  4312. $defaultStateCmd = 0;
  4313. } elsif ($defaultState eq "on") {
  4314. $defaultStateCmd = 1;
  4315. } elsif ($defaultState eq "last") {
  4316. $defaultStateCmd = 2;
  4317. } else {
  4318. $defaultStateCmd = 0;
  4319. }
  4320. my $localControl = ReadingsVal($name, "localControl", "disabled");
  4321. my $localControlCmd = ($localControl eq "enabled")? 1:0;
  4322. my $overCurrentShutdown = ReadingsVal($name, "overCurrentShutdown", "off");
  4323. my $overCurrentShutdownCmd = ($overCurrentShutdown eq "restart")? 1:0;
  4324. my $overCurrentShutdownReset = "not_active";
  4325. my $overCurrentShutdownResetCmd = 0;
  4326. my $rampTime1 = ReadingsVal($name, "rampTime1", 0);
  4327. my $rampTime1Cmd = $rampTime1 * 2;
  4328. if ($rampTime1Cmd <= 0) {
  4329. $rampTime1Cmd = 0;
  4330. } elsif ($rampTime1Cmd >= 15) {
  4331. $rampTime1Cmd = 15;
  4332. }
  4333. my $rampTime2 = ReadingsVal($name, "rampTime2", 0);
  4334. my $rampTime2Cmd = $rampTime2 * 2;
  4335. if ($rampTime2Cmd <= 0) {
  4336. $rampTime2Cmd = 0;
  4337. } elsif ($rampTime2Cmd >= 15) {
  4338. $rampTime2Cmd = 15;
  4339. }
  4340. my $rampTime3 = ReadingsVal($name, "rampTime3", 0);
  4341. my $rampTime3Cmd = $rampTime3 * 2;
  4342. if ($rampTime3Cmd <= 0) {
  4343. $rampTime3Cmd = 0;
  4344. } elsif ($rampTime3Cmd >= 15) {
  4345. $rampTime3Cmd = 15;
  4346. }
  4347. my $teachInDev = ReadingsVal($name, "teachInDev", "disabled");
  4348. my $teachInDevCmd = ($teachInDev eq "enabled")? 1:0;
  4349. my $localCmd = shift(@a);
  4350. my $localCmdVal = shift(@a);
  4351. if ($localCmd eq "dayNight") {
  4352. if ($localCmdVal eq "day") {
  4353. $dayNight = "day";
  4354. $dayNightCmd = 0;
  4355. } elsif ($localCmdVal eq "night") {
  4356. $dayNight = "night";
  4357. $dayNightCmd = 1;
  4358. } else {
  4359. return "Usage: $cmd $localCmd <value> wrong, choose day night.";
  4360. }
  4361. } elsif ($localCmd eq "defaultState"){
  4362. if ($localCmdVal eq "off") {
  4363. $defaultState = "off";
  4364. $defaultStateCmd = 0;
  4365. } elsif ($localCmdVal eq "on") {
  4366. $defaultState = "on";
  4367. $defaultStateCmd = 1;
  4368. } elsif ($localCmdVal eq "last") {
  4369. $defaultState = "last";
  4370. $defaultStateCmd = 2;
  4371. } else {
  4372. return "Usage: $cmd $localCmd <value> wrong, choose on off last.";
  4373. }
  4374. } elsif ($localCmd eq "localControl"){
  4375. if ($localCmdVal eq "disabled") {
  4376. $localControl = "disabled";
  4377. $localControlCmd = 0;
  4378. } elsif ($localCmdVal eq "enabled") {
  4379. $localControl = "enabled";
  4380. $localControlCmd = 1;
  4381. } else {
  4382. return "Usage: $cmd $localCmd <value> wrong, choose disabled enabled.";
  4383. }
  4384. } elsif ($localCmd eq "overCurrentShutdown"){
  4385. if ($localCmdVal eq "off") {
  4386. $overCurrentShutdown = "off";
  4387. $overCurrentShutdownCmd = 0;
  4388. } elsif ($localCmdVal eq "restart") {
  4389. $overCurrentShutdown = "restart";
  4390. $overCurrentShutdownCmd = 1;
  4391. } else {
  4392. return "Usage: $cmd $localCmd <value> wrong, choose off restart.";
  4393. }
  4394. } elsif ($localCmd eq "overCurrentShutdownReset"){
  4395. if ($localCmdVal eq "not_active") {
  4396. $overCurrentShutdownReset = "not_active";
  4397. $overCurrentShutdownResetCmd = 0;
  4398. } elsif ($localCmdVal eq "trigger") {
  4399. $overCurrentShutdownReset = "trigger";
  4400. $overCurrentShutdownResetCmd = 1;
  4401. } else {
  4402. return "Usage: $cmd $localCmd <value> wrong, choose not_active trigger.";
  4403. }
  4404. } elsif ($localCmd eq "rampTime1"){
  4405. if ($localCmdVal >= 0 || $localCmdVal <= 7.5) {
  4406. $rampTime1 = $localCmdVal;
  4407. $rampTime1Cmd = $localCmdVal * 2;
  4408. } else {
  4409. return "Usage: $cmd $localCmd <value> wrong, choose 0, 0.5, ..., 7, 7.5";
  4410. }
  4411. } elsif ($localCmd eq "rampTime2"){
  4412. if ($localCmdVal >= 0 || $localCmdVal <= 7.5) {
  4413. $rampTime2 = $localCmdVal;
  4414. $rampTime2Cmd = $localCmdVal * 2;
  4415. } else {
  4416. return "Usage: $cmd $localCmd <value> wrong, choose 0, 0.5, ..., 7, 7.5";
  4417. }
  4418. } elsif ($localCmd eq "rampTime3"){
  4419. if ($localCmdVal >= 0 || $localCmdVal <= 7.5) {
  4420. $rampTime3 = $localCmdVal;
  4421. $rampTime3Cmd = $localCmdVal * 2;
  4422. } else {
  4423. return "Usage: $cmd $localCmd <value> wrong, choose 0, 0.5, ..., 7, 7.5";
  4424. }
  4425. } elsif ($localCmd eq "teachInDev"){
  4426. if ($localCmdVal eq "disabled") {
  4427. $teachInDev = "disabled";
  4428. $teachInDevCmd = 0;
  4429. } elsif ($localCmdVal eq "enabled") {
  4430. $teachInDev = "enabled";
  4431. $teachInDevCmd = 1;
  4432. } else {
  4433. return "Usage: $cmd $localCmd <value> wrong, choose disabled enabled.";
  4434. }
  4435. } else {
  4436. return "Usage: $cmd <localCmd> wrong, choose dayNight|defaultState|localControl|" .
  4437. "overCurrentShutdown|overCurrentShutdownReset|rampTime1|rampTime2|rampTime3|teachInDev.";
  4438. }
  4439. readingsSingleUpdate($hash, "dayNight", $dayNight, 1);
  4440. readingsSingleUpdate($hash, "defaultState", $defaultState, 1);
  4441. readingsSingleUpdate($hash, "localControl", $localControl, 1);
  4442. readingsSingleUpdate($hash, "overCurrentShutdown", $overCurrentShutdown, 1);
  4443. readingsSingleUpdate($hash, "overCurrentShutdownReset", $overCurrentShutdownReset, 1);
  4444. readingsSingleUpdate($hash, "rampTime1", $rampTime1, 1);
  4445. readingsSingleUpdate($hash, "rampTime2", $rampTime2, 1);
  4446. readingsSingleUpdate($hash, "rampTime3", $rampTime3, 1);
  4447. readingsSingleUpdate($hash, "teachInDev", $teachInDev, 1);
  4448. $data = sprintf "%02X%02X%02X%02X", $teachInDevCmd << 7 | $cmdID,
  4449. $overCurrentShutdownCmd << 7 | $overCurrentShutdownResetCmd << 6 | $localControlCmd << 5 | $channel,
  4450. int($rampTime2Cmd) << 4 | int($rampTime3Cmd),
  4451. $dayNightCmd << 7 | $defaultStateCmd << 4 | int($rampTime1Cmd);
  4452. } elsif ($cmd eq "measurement") {
  4453. shift(@a);
  4454. $updateState = 0;
  4455. $cmdID = 5;
  4456. # same configuration for all channels
  4457. $channel = 30;
  4458. my $measurementMode = ReadingsVal($name, "measurementMode", "energy");
  4459. my $measurementModeCmd = ($measurementMode eq "power")? 0:1;
  4460. my $measurementReport = ReadingsVal($name, "measurementReport", "query");
  4461. my $measurementReportCmd = ($measurementReport eq "auto")? 0:1;
  4462. my $measurementReset = "not_active";
  4463. my $measurementResetCmd = 0;
  4464. my $measurementDelta = int(ReadingsVal($name, "measurementDelta", 0));
  4465. if ($measurementDelta <= 0) {
  4466. $measurementDelta = 0;
  4467. } elsif ($measurementDelta >= 4095) {
  4468. $measurementDelta = 4095;
  4469. }
  4470. my $unit = ReadingsVal($name, "measurementUnit", "Ws");
  4471. my $unitCmd;
  4472. if ($unit eq "Ws") {
  4473. $unitCmd = 0;
  4474. } elsif ($unit eq "Wh") {
  4475. $unitCmd = 1;
  4476. } elsif ($unit eq "KWh") {
  4477. $unitCmd = 2;
  4478. } elsif ($unit eq "W") {
  4479. $unitCmd = 3;
  4480. } elsif ($unit eq "KW") {
  4481. $unitCmd = 4;
  4482. } else {
  4483. $unitCmd = 0;
  4484. }
  4485. my $responseTimeMax = ReadingsVal($name, "responseTimeMax", 10);
  4486. my $responseTimeMaxCmd = $responseTimeMax / 10;
  4487. if ($responseTimeMaxCmd <= 1) {
  4488. $responseTimeMaxCmd = 1;
  4489. } elsif ($responseTimeMaxCmd >= 255) {
  4490. $responseTimeMaxCmd = 255;
  4491. }
  4492. my $responseTimeMin = ReadingsVal($name, "responseTimeMin", 1);
  4493. if ($responseTimeMin <= 1) {
  4494. $responseTimeMin = 1;
  4495. } elsif ($responseTimeMin >= 255) {
  4496. $responseTimeMin = 255;
  4497. }
  4498. my $measurementCmd = shift(@a);
  4499. my $measurementCmdVal = shift(@a);
  4500. if (!defined $measurementCmdVal) {
  4501. return "Usage: $cmd $measurementCmd <value> needed.";
  4502. }
  4503. if (!defined $measurementCmd) {
  4504. return "Usage: $cmd <measurementCmd> wrong, choose mode|report|" .
  4505. "reset|delta|unit|responseTimeMax|responseTimeMin.";
  4506. } elsif ($measurementCmd eq "mode") {
  4507. if ($measurementCmdVal eq "energy") {
  4508. $measurementMode = "energy";
  4509. $measurementModeCmd = 0;
  4510. } elsif ($measurementCmdVal eq "power") {
  4511. $measurementMode = "power";
  4512. $measurementModeCmd = 1;
  4513. } else {
  4514. return "Usage: $cmd $measurementCmd <value> wrong, choose energy power.";
  4515. }
  4516. } elsif ($measurementCmd eq "report"){
  4517. if ($measurementCmdVal eq "query") {
  4518. $measurementReport = "query";
  4519. $measurementReportCmd = 0;
  4520. } elsif ($measurementCmdVal eq "auto") {
  4521. $measurementReport = "auto";
  4522. $measurementReportCmd = 1;
  4523. } else {
  4524. return "Usage: $cmd $measurementCmd <value> wrong, choose query auto.";
  4525. }
  4526. } elsif ($measurementCmd eq "reset"){
  4527. if ($measurementCmdVal eq "not_active") {
  4528. $measurementReset = "not_active";
  4529. $measurementResetCmd = 0;
  4530. } elsif ($measurementCmdVal eq "trigger") {
  4531. $measurementReset = "trigger";
  4532. $measurementResetCmd = 1;
  4533. } else {
  4534. return "Usage: $cmd $measurementCmd <value> wrong, choose not_active trigger.";
  4535. }
  4536. } elsif ($measurementCmd eq "unit"){
  4537. if ($measurementCmdVal eq "Ws") {
  4538. $unit = "Ws";
  4539. $unitCmd = 0;
  4540. } elsif ($measurementCmdVal eq "Wh") {
  4541. $unit = "Wh";
  4542. $unitCmd = 1;
  4543. } elsif ($measurementCmdVal eq "KWh") {
  4544. $unit = "KWh";
  4545. $unitCmd = 2;
  4546. } elsif ($measurementCmdVal eq "W") {
  4547. $unit = "W";
  4548. $unitCmd = 3;
  4549. } elsif ($measurementCmdVal eq "KW") {
  4550. $unit = "KW";
  4551. $unitCmd = 4;
  4552. } else {
  4553. return "Usage: $cmd $measurementCmd <value> wrong, choose Ws Wh KWh W KW.";
  4554. }
  4555. } elsif ($measurementCmd eq "delta"){
  4556. if ($measurementCmdVal >= 0 || $measurementCmdVal <= 4095) {
  4557. $measurementDelta = int($measurementCmdVal);
  4558. } else {
  4559. return "Usage: $cmd $measurementCmd <value> wrong, choose 0 ... 4095";
  4560. }
  4561. } elsif ($measurementCmd eq "responseTimeMax"){
  4562. if ($measurementCmdVal >= 10 || $measurementCmdVal <= 2550) {
  4563. $responseTimeMax = int($measurementCmdVal);
  4564. $responseTimeMaxCmd = int($measurementCmdVal) / 10;
  4565. } else {
  4566. return "Usage: $cmd $measurementCmd <value> wrong, choose 10 ... 2550";
  4567. }
  4568. } elsif ($measurementCmd eq "responseTimeMin"){
  4569. if ($measurementCmdVal >= 1 || $measurementCmdVal <= 255) {
  4570. $responseTimeMin = int($measurementCmdVal);
  4571. } else {
  4572. return "Usage: $cmd $measurementCmd <value> wrong, choose 1 ... 255";
  4573. }
  4574. } else {
  4575. return "Usage: $cmd <measurementCmd> wrong, choose mode|report|" .
  4576. "reset|delta|unit|responseTimeMax|responseTimeMin.";
  4577. }
  4578. readingsSingleUpdate($hash, "measurementMode", $measurementMode, 1);
  4579. readingsSingleUpdate($hash, "measurementReport", $measurementReport, 1);
  4580. readingsSingleUpdate($hash, "measurementReset", $measurementReset, 1);
  4581. readingsSingleUpdate($hash, "measurementDelta", $measurementDelta, 1);
  4582. readingsSingleUpdate($hash, "measurementUnit", $unit, 1);
  4583. readingsSingleUpdate($hash, "responseTimeMax", $responseTimeMax, 1);
  4584. readingsSingleUpdate($hash, "responseTimeMin", $responseTimeMin, 1);
  4585. $data = sprintf "%02X%02X%02X%02X%02X%02X", $cmdID,
  4586. $measurementReportCmd << 7 | $measurementResetCmd << 6 | $measurementModeCmd << 5 | $channel,
  4587. ($measurementDelta | 0x0F) << 4 | $unitCmd, ($measurementDelta | 0xFF00) >> 8,
  4588. $responseTimeMax, $responseTimeMin;
  4589. } elsif ($cmd eq "roomCtrlMode") {
  4590. shift(@a);
  4591. $updateState = 0;
  4592. $cmdID = 8;
  4593. my $roomCtrlModeCmd = shift(@a);
  4594. return "$cmd <channel> <roomCtrlMode> is missing, choose off|comfort|comfort-1|comfort-2|economy|buildingProtection." if (!defined $roomCtrlModeCmd);
  4595. if ($roomCtrlModeCmd eq "off") {
  4596. $roomCtrlModeCmd = 0;
  4597. } elsif ($roomCtrlModeCmd eq "comfort") {
  4598. $roomCtrlModeCmd = 1;
  4599. } elsif ($roomCtrlModeCmd eq "economy") {
  4600. $roomCtrlModeCmd = 2;
  4601. } elsif ($roomCtrlModeCmd eq "buildingProtection") {
  4602. $roomCtrlModeCmd = 3;
  4603. } elsif ($roomCtrlModeCmd eq "comfort-1") {
  4604. $roomCtrlModeCmd = 4;
  4605. } elsif ($roomCtrlModeCmd eq "comfort-2") {
  4606. $roomCtrlModeCmd = 5;
  4607. } else {
  4608. return "$cmd <channel> <roomCtrlMode> wrong, choose off|comfort|comfort-1|comfort-2|economy|buildingProtection.";
  4609. }
  4610. $data = sprintf "%02X%02X", $cmdID, $roomCtrlModeCmd;
  4611. } elsif ($cmd eq "autoOffTime") {
  4612. shift(@a);
  4613. $updateState = 0;
  4614. $cmdID = 0x0B;
  4615. $outputVal = int(shift(@a) * 10);
  4616. if (!defined $outputVal || $outputVal !~ m/^[+-]?\d+$/ || $outputVal < 0 || $outputVal > 65534) {
  4617. return "Usage: $cmd variable is not numeric or out of range.";
  4618. }
  4619. $channel = shift(@a);
  4620. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4621. if (!defined $channel || $channel eq "all") {
  4622. CommandDeleteReading(undef, "$name autoOffTime.*");
  4623. $channel = 30;
  4624. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4625. $channel = 31;
  4626. } elsif ($channel + 0 >= 30) {
  4627. CommandDeleteReading(undef, "$name autoOffTime.*");
  4628. $channel = 30;
  4629. } elsif ($channel >= 0 && $channel <= 29) {
  4630. } else {
  4631. return "$cmd $channel wrong, choose 0...31|all|input.";
  4632. }
  4633. my $extSwitchMode = ReadingsVal($name, "extSwitchMode", 'unavailable');
  4634. my %extSwitchMode = (
  4635. "unavailable" => 0,
  4636. "switch" => 1,
  4637. "pushbutton" => 2,
  4638. "auto" => 3
  4639. );
  4640. if (exists $extSwitchMode{$extSwitchMode}) {
  4641. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4642. } else {
  4643. $extSwitchMode = 0;
  4644. }
  4645. my $extSwitchType = ReadingsVal($name, "extSwitchType", 'toggle') eq 'direction' ? 1 : 0;
  4646. $data = sprintf "%02X%02X%04XFFFF%02X", $cmdID, $channel, $outputVal, $extSwitchMode << 6 | $extSwitchType << 5;
  4647. } elsif ($cmd eq "delayOffTime") {
  4648. shift(@a);
  4649. $updateState = 0;
  4650. $cmdID = 0x0B;
  4651. $outputVal = int(shift(@a) * 10);
  4652. if (!defined $outputVal || $outputVal !~ m/^[+-]?\d+$/ || $outputVal < 0 || $outputVal > 65534) {
  4653. return "Usage: $cmd variable is not numeric or out of range.";
  4654. }
  4655. $channel = shift(@a);
  4656. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4657. if (!defined $channel || $channel eq "all") {
  4658. CommandDeleteReading(undef, "$name delayOffTime.*");
  4659. $channel = 30;
  4660. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4661. $channel = 31;
  4662. } elsif ($channel + 0 >= 30) {
  4663. CommandDeleteReading(undef, "$name delayOffTime.*");
  4664. $channel = 30;
  4665. } elsif ($channel >= 0 && $channel <= 29) {
  4666. } else {
  4667. return "$cmd $channel wrong, choose 0...31|all|input.";
  4668. }
  4669. my $extSwitchMode = ReadingsVal($name, "extSwitchMode", 'unavailable');
  4670. my %extSwitchMode = (
  4671. "unavailable" => 0,
  4672. "switch" => 1,
  4673. "pushbutton" => 2,
  4674. "auto" => 3
  4675. );
  4676. if (exists $extSwitchMode{$extSwitchMode}) {
  4677. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4678. } else {
  4679. $extSwitchMode = 0;
  4680. }
  4681. my $extSwitchType = ReadingsVal($name, "extSwitchType", 'toggle') eq 'direction' ? 1 : 0;
  4682. $data = sprintf "%02X%02XFFFF%04X%02X", $cmdID, $channel, $outputVal, $extSwitchMode << 6 | $extSwitchType << 5;
  4683. } elsif ($cmd eq "extSwitchMode") {
  4684. shift(@a);
  4685. $updateState = 0;
  4686. $cmdID = 0x0B;
  4687. my $extSwitchMode = shift(@a);
  4688. return "Usage: $cmd variable is missing, choose unavailable|switch|pushbutton|auto." if (!defined $extSwitchMode);
  4689. my %extSwitchMode = (
  4690. "unavailable" => 0,
  4691. "switch" => 1,
  4692. "pushbutton" => 2,
  4693. "auto" => 3
  4694. );
  4695. if (exists $extSwitchMode{$extSwitchMode}) {
  4696. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4697. } else {
  4698. return "Usage: $cmd variable wrong, choose unavailable|switch|pushbutton|auto.";
  4699. }
  4700. $channel = shift(@a);
  4701. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4702. if (!defined $channel || $channel eq "all") {
  4703. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4704. $channel = 30;
  4705. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4706. $channel = 31;
  4707. } elsif ($channel + 0 >= 30) {
  4708. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4709. $channel = 30;
  4710. } elsif ($channel >= 0 && $channel <= 29) {
  4711. } else {
  4712. return "$cmd $channel wrong, choose 0...31|all|input.";
  4713. }
  4714. my $extSwitchType = ReadingsVal($name, "extSwitchType", 'toggle') eq 'direction' ? 1 : 0;
  4715. $data = sprintf "%02X%02XFFFFFFFF%02X", $cmdID, $channel, $extSwitchMode << 6 | $extSwitchType << 5;
  4716. } elsif ($cmd eq "extSwitchType") {
  4717. shift(@a);
  4718. $updateState = 0;
  4719. $cmdID = 0x0B;
  4720. my $extSwitchType = shift(@a);
  4721. return "Usage: $cmd variable is missing, choose toggle|direction." if (!defined $extSwitchType);
  4722. my %extSwitchType = (
  4723. "toggle" => 0,
  4724. "direction" => 1,
  4725. );
  4726. if (exists $extSwitchType{$extSwitchType}) {
  4727. $extSwitchType = $extSwitchType{$extSwitchType};
  4728. } else {
  4729. return "Usage: $cmd variable wrong, choose toggle|direction.";
  4730. }
  4731. $channel = shift(@a);
  4732. $channel = AttrVal($name, "defaultChannel", AttrVal($name, "devChannel", undef)) if (!defined $channel);
  4733. if (!defined $channel || $channel eq "all") {
  4734. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4735. $channel = 30;
  4736. } elsif ($channel eq "input" || $channel + 0 == 31) {
  4737. $channel = 31;
  4738. } elsif ($channel + 0 >= 30) {
  4739. CommandDeleteReading(undef, "$name extSwitchMode.*");
  4740. $channel = 30;
  4741. } elsif ($channel >= 0 && $channel <= 29) {
  4742. } else {
  4743. return "$cmd $channel wrong, choose 0...31|all|input.";
  4744. }
  4745. my $extSwitchMode = ReadingsVal($name, "extSwitchMode", 'unavailable');
  4746. my %extSwitchMode = (
  4747. "unavailable" => 0,
  4748. "switch" => 1,
  4749. "pushbutton" => 2,
  4750. "auto" => 3
  4751. );
  4752. if (exists $extSwitchMode{$extSwitchMode}) {
  4753. $extSwitchMode = $extSwitchMode{$extSwitchMode};
  4754. } else {
  4755. $extSwitchMode = 0;
  4756. }
  4757. $data = sprintf "%02X%02XFFFFFFFF%02X", $cmdID, $channel, $extSwitchMode << 6 | $extSwitchType << 5;
  4758. } elsif ($cmd eq "special") {
  4759. $rorg = "D1";
  4760. shift(@a);
  4761. $updateState = 0;
  4762. my $repeaterActive = 0;
  4763. my $repeaterLevel = 0;
  4764. my $specialCmd = shift(@a);
  4765. if ($manufID eq "046") {
  4766. if (!defined $specialCmd) {
  4767. return "$cmd <command> wrong, choose repeaterLevel.";
  4768. } elsif ($specialCmd eq "repeaterLevel") {
  4769. $cmdID = 8;
  4770. my $repeaterLevel = shift(@a);
  4771. if (defined $repeaterLevel && $repeaterLevel =~ m/^off|1|2$/) {
  4772. if ($repeaterLevel eq "off") {
  4773. $repeaterLevel = 0;
  4774. } else {
  4775. $repeaterActive = 1;
  4776. }
  4777. } else {
  4778. return "Usage: repeaterLevel is wrong";
  4779. }
  4780. } else {
  4781. return "$cmd $specialCmd <arg> wrong, choose repeaterLevel off|1|2.";
  4782. }
  4783. }
  4784. $data = sprintf "0046%02X%02X%02X", $cmdID, $repeaterActive, $repeaterLevel;
  4785. } else {
  4786. if ($manufID =~ m/^046$/) {
  4787. $cmdList .= "dim:slider,0,1,100 on off autoOffTime delayOffTime extSwitchMode extSwitchType local measurement roomCtrlMode:off,buildingProtection,economy,comfort-2,comfort-1,comfort special";
  4788. } else {
  4789. $cmdList .= "dim:slider,0,1,100 on off autoOffTime delayOffTime extSwitchMode extSwitchType local measurement roomCtrlMode:off,buildingProtection,economy,comfort-2,comfort-1,comfort";
  4790. }
  4791. return SetExtensions ($hash, $cmdList, $name, @a);
  4792. }
  4793. Log3 $name, 3, "EnOcean set $name $cmd";
  4794. } elsif ($st =~ m/^blindsCtrl\.0[01]$/) {
  4795. # Blinds Control for Position and Angle
  4796. # (D2-05-xx)
  4797. $rorg = "D2";
  4798. $updateState = 0;
  4799. my $cmdID;
  4800. my $channel = AttrVal($name, "defaultChannel", 'all');
  4801. my $position = 127;
  4802. my $angle = 127;
  4803. my $repo = AttrVal($name, "reposition", "directly");
  4804. if ($repo eq "directly") {
  4805. $repo = 0;
  4806. } elsif ($repo eq "opens") {
  4807. $repo = 1;
  4808. } elsif ($repo eq "closes") {
  4809. $repo = 2;
  4810. } else {
  4811. $repo = 0;
  4812. }
  4813. my $lock = 0;
  4814. if ($cmd =~ m/^\d+$/) {
  4815. # interpretive numeric value as position
  4816. unshift(@a, 'position');
  4817. $cmd = 'position';
  4818. }
  4819. if ($cmd eq "position") {
  4820. $cmdID = 1;
  4821. shift(@a);
  4822. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4823. return "Attention: Device locked";
  4824. }
  4825. if (defined $a[0]) {
  4826. # position value
  4827. if (($a[0] =~ m/^\d+$/) && ($a[0] >= 0) && ($a[0] <= 100)) {
  4828. $position = shift(@a);
  4829. if (defined $a[0]) {
  4830. # angle value
  4831. if (($a[0] =~ m/^\d+$/) && ($a[0] >= 0) && ($a[0] <= 100)) {
  4832. $angle = shift(@a);
  4833. if (defined $a[0]) {
  4834. # channel
  4835. $channel = shift(@a);
  4836. if ($channel =~ m/^all$/) {
  4837. $channel = 15;
  4838. } elsif ($channel =~ m/^[1234]$/) {
  4839. $channel -= 1;
  4840. } else {
  4841. return "Usage: $position $angle $channel argument unknown, choose one of 1|2|3|4|all";
  4842. }
  4843. } else {
  4844. $channel = 15;
  4845. }
  4846. if (defined $a[0]) {
  4847. # reposition value
  4848. $repo = shift(@a);
  4849. if ($repo eq "directly") {
  4850. $repo = 0;
  4851. } elsif ($repo eq "opens") {
  4852. $repo = 1;
  4853. } elsif ($repo eq "closes") {
  4854. $repo = 2;
  4855. } else {
  4856. return "Usage: $position $angle $channel $repo argument unknown, choose one of directly opens closes";
  4857. }
  4858. }
  4859. readingsSingleUpdate($hash, "anglePos", $angle, 1);
  4860. } else {
  4861. return "Usage: $position $a[0] is not numeric or out of range";
  4862. }
  4863. } else {
  4864. $channel = 15;
  4865. }
  4866. readingsSingleUpdate($hash, "state", "in_motion", 1);
  4867. } else {
  4868. return "Usage: $a[0] is not numeric or out of range";
  4869. }
  4870. } else {
  4871. return "Usage: set <name> position <position> [<angle> [<repo>]]";
  4872. }
  4873. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4874. } elsif ($cmd eq "anglePos") {
  4875. $cmdID = 1;
  4876. shift(@a);
  4877. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4878. return "Attention: Device locked";
  4879. }
  4880. if (defined $a[0]) {
  4881. if (($a[0] =~ m/^\d+$/) && ($a[0] >= 0) && ($a[0] <= 100)) {
  4882. $angle = shift(@a);
  4883. if (defined $a[0]) {
  4884. # channel
  4885. $channel = shift(@a);
  4886. if ($channel =~ m/^all$/) {
  4887. $channel = 15;
  4888. } elsif ($channel =~ m/^[1234]$/) {
  4889. $channel -= 1;
  4890. } else {
  4891. return "Usage: $angle $channel argument unknown, choose one of 1|2|3|4|all";
  4892. }
  4893. } else {
  4894. $channel = 15;
  4895. }
  4896. readingsSingleUpdate($hash, "state", "in_motion", 1);
  4897. } else {
  4898. return "Usage: $a[0] is not numeric or out of range";
  4899. }
  4900. } else {
  4901. return "Usage: set <name> anglePos <angle>";
  4902. }
  4903. $repo = 0;
  4904. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4905. } elsif ($cmd eq "stop") {
  4906. $cmdID = 2;
  4907. shift(@a);
  4908. if (defined $a[0]) {
  4909. # channel
  4910. $channel = shift(@a);
  4911. if ($channel =~ m/^all$/) {
  4912. $channel = 15;
  4913. } elsif ($channel =~ m/^[1234]$/) {
  4914. $channel -= 1;
  4915. } else {
  4916. return "Usage: stop $channel argument unknown, choose one of 1|2|3|4|all";
  4917. }
  4918. } else {
  4919. $channel = 15;
  4920. }
  4921. readingsSingleUpdate($hash, "state", "stopped", 1);
  4922. $data = sprintf "%02X", $channel << 4 | $cmdID;
  4923. } elsif ($cmd eq "opens") {
  4924. $cmdID = 1;
  4925. shift(@a);
  4926. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4927. return "Attention: Device locked";
  4928. }
  4929. if (defined $a[0]) {
  4930. # channel
  4931. $channel = shift(@a);
  4932. if ($channel =~ m/^all$/) {
  4933. $channel = 15;
  4934. } elsif ($channel =~ m/^[1234]$/) {
  4935. $channel -= 1;
  4936. } else {
  4937. return "Usage: opens $channel argument unknown, choose one of 1|2|3|4|all";
  4938. }
  4939. } else {
  4940. $channel = 15;
  4941. }
  4942. $position = 0;
  4943. $repo = 0;
  4944. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4945. } elsif ($cmd eq "closes") {
  4946. $cmdID = 1;
  4947. shift(@a);
  4948. if (ReadingsVal($name, "block", "unlock") ne "unlock") {
  4949. return "Attention: Device locked";
  4950. }
  4951. if (defined $a[0]) {
  4952. # channel
  4953. $channel = shift(@a);
  4954. if ($channel =~ m/^all$/) {
  4955. $channel = 15;
  4956. } elsif ($channel =~ m/^[1234]$/) {
  4957. $channel -= 1;
  4958. } else {
  4959. return "Usage: closes $channel argument unknown, choose one of 1|2|3|4|all";
  4960. }
  4961. } else {
  4962. $channel = 15;
  4963. }
  4964. $position = 100;
  4965. $repo = 0;
  4966. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4967. } elsif ($cmd eq "unlock") {
  4968. $cmdID = 1;
  4969. shift(@a);
  4970. if (defined $a[0]) {
  4971. # channel
  4972. $channel = shift(@a);
  4973. if ($channel =~ m/^all$/) {
  4974. $channel = 15;
  4975. } elsif ($channel =~ m/^[1234]$/) {
  4976. $channel -= 1;
  4977. } else {
  4978. return "Usage: unlock $channel argument unknown, choose one of 1|2|3|4|all";
  4979. }
  4980. } else {
  4981. $channel = 15;
  4982. }
  4983. $repo = 0;
  4984. $lock = 7;
  4985. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  4986. } elsif ($cmd eq "lock") {
  4987. $cmdID = 1;
  4988. shift(@a);
  4989. if (defined $a[0]) {
  4990. # channel
  4991. $channel = shift(@a);
  4992. if ($channel =~ m/^all$/) {
  4993. $channel = 15;
  4994. } elsif ($channel =~ m/^[1234]$/) {
  4995. $channel -= 1;
  4996. } else {
  4997. return "Usage: lock $channel argument unknown, choose one of 1|2|3|4|all";
  4998. }
  4999. } else {
  5000. $channel = 15;
  5001. }
  5002. $repo = 0;
  5003. $lock = 1;
  5004. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  5005. } elsif ($cmd eq "alarm") {
  5006. $cmdID = 1;
  5007. shift(@a);
  5008. if (defined $a[0]) {
  5009. # channel
  5010. $channel = shift(@a);
  5011. if ($channel =~ m/^all$/) {
  5012. $channel = 15;
  5013. } elsif ($channel =~ m/^[1234]$/) {
  5014. $channel -= 1;
  5015. } else {
  5016. return "Usage: alarm $channel argument unknown, choose one of 1|2|3|4|all";
  5017. }
  5018. } else {
  5019. $channel = 15;
  5020. }
  5021. $repo = 0;
  5022. $lock = 2;
  5023. $data = sprintf "%02X%02X%02X%02X", $position, $angle, $repo << 4 | $lock, $channel << 4 | $cmdID;
  5024. } else {
  5025. $cmdList .= "position:slider,0,1,100 anglePos:slider,0,1,100 stop opens closes lock unlock alarm";
  5026. return "Unknown argument $cmd, choose one of $cmdList";
  5027. }
  5028. Log3 $name, 3, "EnOcean set $name $cmd";
  5029. } elsif ($st eq "multisensor.01") {
  5030. #####
  5031. # Multisensor Windows Handle
  5032. # (D2-06-01)
  5033. $rorg = "D2";
  5034. $updateState = 2;
  5035. my $waitingCmds = ReadingsVal($name, "waitingCmds", undef);
  5036. if (defined $waitingCmds) {
  5037. # check presence state
  5038. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? $waitingCmds & 0xDF | 32 : $waitingCmds & 0xDF;
  5039. } else {
  5040. $waitingCmds = ReadingsVal($name, "presence", "present") eq "absent" ? 32 : 0;
  5041. }
  5042. if ($cmd eq "presence") {
  5043. # set presence
  5044. if (defined $a[1]) {
  5045. if ($a[1] =~ m/^absent$/) {
  5046. readingsSingleUpdate($hash, "presence", $a[1], 1);
  5047. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5048. shift(@a);
  5049. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xDF | 32, 0);
  5050. } elsif ($a[1] =~ m/^present$/) {
  5051. readingsSingleUpdate($hash, "presence", $a[1], 1);
  5052. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5053. shift(@a);
  5054. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xDF, 0);
  5055. } else {
  5056. return "Usage: $a[1] is not numeric or out of range";
  5057. }
  5058. }
  5059. } elsif ($cmd eq "handleClosedClick") {
  5060. # set battery closed click
  5061. if (defined $a[1]) {
  5062. if ($a[1] =~ m/^disable$/) {
  5063. readingsSingleUpdate($hash, "handleClosedClick", $a[1] . 'd', 1);
  5064. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5065. shift(@a);
  5066. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xE7 | 8, 0);
  5067. } elsif ($a[1] =~ m/^enable$/) {
  5068. readingsSingleUpdate($hash, "handleClosedClick", $a[1] . 'd', 1);
  5069. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5070. shift(@a);
  5071. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xE7 | 16, 0);
  5072. } else {
  5073. return "Usage: $a[1] is not numeric or out of range";
  5074. }
  5075. }
  5076. } elsif ($cmd eq "batteryLowClick") {
  5077. # set battery click low
  5078. if (defined $a[1]) {
  5079. if ($a[1] =~ m/^disable$/) {
  5080. readingsSingleUpdate($hash, "batteryLowClick", $a[1] . 'd', 1);
  5081. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5082. shift(@a);
  5083. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xF9 | 2, 0);
  5084. } elsif ($a[1] =~ m/^enable$/) {
  5085. readingsSingleUpdate($hash, "batteryLowClick", $a[1] . 'd', 1);
  5086. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5087. shift(@a);
  5088. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds & 0xF9 | 4, 0);
  5089. } else {
  5090. return "Usage: $a[1] is not numeric or out of range";
  5091. }
  5092. }
  5093. } elsif ($cmd eq "updateInterval") {
  5094. # set update interval
  5095. if (defined $a[1]) {
  5096. if ($a[1] =~ m/^\d+$/ && $a[1] >= 5 && $a[1] <= 65535) {
  5097. readingsSingleUpdate($hash, "updateInterval", $a[1], 1);
  5098. readingsSingleUpdate($hash, "updateIntervalSet", $a[1], 0);
  5099. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5100. shift(@a);
  5101. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 1, 0);
  5102. } else {
  5103. return "Usage: $a[1] is not numeric or out of range";
  5104. }
  5105. }
  5106. } elsif ($cmd eq "blinkInterval") {
  5107. # set blick interval
  5108. if (defined $a[1]) {
  5109. if ($a[1] =~ m/^\d+$/ && $a[1] >= 3 && $a[1] <= 255) {
  5110. readingsSingleUpdate($hash, "blinkInterval", $a[1], 1);
  5111. readingsSingleUpdate($hash, "blinkIntervalSet", $a[1], 0);
  5112. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5113. shift(@a);
  5114. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds | 1, 0);
  5115. } else {
  5116. return "Usage: $a[1] is not numeric or out of range";
  5117. }
  5118. }
  5119. } elsif ($cmd eq "teachSlave") {
  5120. # teach slave
  5121. $updateState = 0;
  5122. $destinationID = "FFFFFFFF";
  5123. if (defined $a[1]) {
  5124. if ($a[1] =~ m/^contact$/) {
  5125. $rorg = "D5";
  5126. $data = '00';
  5127. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefW", "biDir");
  5128. readingsSingleUpdate($hash, "teachSlave", '1BS teach-in sent', 1);
  5129. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5130. shift(@a);
  5131. } elsif ($a[1] =~ m/^windowHandleOpen$/) {
  5132. $rorg = "F6";
  5133. $data = 'E0';
  5134. $status = '20';
  5135. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefH", "biDir");
  5136. readingsSingleUpdate($hash, "teachSlave", 'RPS teach-in sent', 1);
  5137. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5138. shift(@a);
  5139. } elsif ($a[1] =~ m/^windowHandleClosed$/) {
  5140. $rorg = "F6";
  5141. $data = 'F0';
  5142. $status = '20';
  5143. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefH", "biDir");
  5144. readingsSingleUpdate($hash, "teachSlave", 'RPS teach-in sent', 1);
  5145. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5146. shift(@a);
  5147. } elsif ($a[1] =~ m/^windowHandleTilted$/) {
  5148. $rorg = "F6";
  5149. $data = 'D0';
  5150. $status = '20';
  5151. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDefH", "biDir");
  5152. readingsSingleUpdate($hash, "teachSlave", 'RPS teach-in sent', 1);
  5153. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5154. shift(@a);
  5155. } else {
  5156. return "Usage: $a[1] is wrong";
  5157. }
  5158. }
  5159. } else {
  5160. $cmdList .= "presence:absent,present handleClosedClick:enable,disable batteryLowClick:enable,disable " .
  5161. "updateInterval blinkInterval teachSlave:contact,windowHandleClosed,windowHandleOpen,windowHandleTilted";
  5162. return "Unknown argument $cmd, choose one of $cmdList";
  5163. }
  5164. } elsif ($st eq "roomCtrlPanel.00") {
  5165. # Room Control Panel
  5166. # (D2-10-00 - D2-10-02)
  5167. $rorg = "D2";
  5168. $updateState = 2;
  5169. if ($cmd eq "desired-temp"|| $cmd eq "setpointTemp") {
  5170. if (defined $a[1]) {
  5171. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 40)) {
  5172. $a[1] = sprintf "%0.1f", $a[1];
  5173. readingsSingleUpdate($hash, "setpointTemp", $a[1], 1);
  5174. readingsSingleUpdate($hash, "setpointTempSet", $a[1], 0);
  5175. Log3 $name, 3, "EnOcean set $name setpointTemp $a[1]";
  5176. shift(@a);
  5177. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5178. } else {
  5179. return "Usage: $a[1] is not numeric or out of range";
  5180. }
  5181. }
  5182. } elsif ($cmd eq "economyTemp" || $cmd eq "preComfortTemp" || $cmd eq "buildingProtectionTemp" || $cmd eq "comfortTemp") {
  5183. if (defined $a[1]) {
  5184. if (($a[1] =~ m/^[+-]?\d+(\.\d+)?$/) && ($a[1] >= 0) && ($a[1] <= 40)) {
  5185. Log3 $name, 3, "EnOcean set $name $cmd $a[1]";
  5186. $cmd =~ s/(\b)([a-z])/$1\u$2/g;
  5187. $a[1] = sprintf "%0.1f", $a[1];
  5188. readingsSingleUpdate($hash, "setpoint" . $cmd, $a[1], 1);
  5189. readingsSingleUpdate($hash, "setpoint" . $cmd . "Set", $a[1], 0);
  5190. shift(@a);
  5191. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 8, 0);
  5192. } else {
  5193. return "Usage: $a[1] is not numeric or out of range";
  5194. }
  5195. }
  5196. } elsif ($cmd eq "fanSpeed") {
  5197. if (defined $a[1]) {
  5198. if ($a[1] >= 0 && $a[1] <= 100) {
  5199. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5200. readingsSingleUpdate($hash, "fanSpeedSet", $a[1], 0);
  5201. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5202. shift(@a);
  5203. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5204. } else {
  5205. return "Usage: $a[1] is wrong.";
  5206. }
  5207. }
  5208. } elsif ($cmd eq "fanSpeedMode") {
  5209. if (defined $a[1]) {
  5210. if ($a[1] =~ m/^(central|local)$/) {
  5211. readingsSingleUpdate($hash, "fanSpeedMode", $a[1], 1);
  5212. readingsSingleUpdate($hash, "fanSpeedModeSet", $a[1], 0);
  5213. Log3 $name, 3, "EnOcean set $name fanSpeedMode $a[1]";
  5214. shift(@a);
  5215. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5216. } else {
  5217. return "Usage: $a[1] is wrong.";
  5218. }
  5219. }
  5220. } elsif ($cmd eq "cooling") {
  5221. if (defined $a[1]) {
  5222. if ($a[1] =~ m/^(on|off|auto|no_change)$/) {
  5223. readingsSingleUpdate($hash, "cooling", $a[1], 1);
  5224. readingsSingleUpdate($hash, "coolingSet", $a[1], 0);
  5225. Log3 $name, 3, "EnOcean set $name cooling $a[1]";
  5226. shift(@a);
  5227. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5228. } else {
  5229. return "Usage: $a[1] is wrong.";
  5230. }
  5231. }
  5232. } elsif ($cmd eq "heating") {
  5233. if (defined $a[1]) {
  5234. if ($a[1] =~ m/^(on|off|auto|no_change)$/) {
  5235. readingsSingleUpdate($hash, "heating", $a[1], 1);
  5236. readingsSingleUpdate($hash, "heatingSet", $a[1], 0);
  5237. Log3 $name, 3, "EnOcean set $name heating $a[1]";
  5238. shift(@a);
  5239. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5240. } else {
  5241. return "Usage: $a[1] is wrong.";
  5242. }
  5243. }
  5244. } elsif ($cmd eq "roomCtrlMode") {
  5245. if (defined $a[1]) {
  5246. if ($a[1] =~ m/^(comfort|preComfort|economy|buildingProtection)$/) {
  5247. readingsSingleUpdate($hash, "roomCtrlMode", $a[1], 1);
  5248. readingsSingleUpdate($hash, "roomCtrlModeSet", $a[1], 0);
  5249. Log3 $name, 3, "EnOcean set $name roomCtrlMode $a[1]";
  5250. shift(@a);
  5251. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5252. } else {
  5253. return "Usage: $a[1] is wrong.";
  5254. }
  5255. }
  5256. } elsif ($cmd eq "config") {
  5257. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 64, 0);
  5258. Log3 $name, 3, "EnOcean set $name $cmd";
  5259. } elsif ($cmd eq "timeProgram") {
  5260. # delete remote and send new time program
  5261. delete $hash->{helper}{4}{telegramWait};
  5262. for (my $messagePartCntr = 1; $messagePartCntr <= 4; $messagePartCntr ++) {
  5263. if (defined AttrVal($name, "timeProgram" . $messagePartCntr, undef)) {
  5264. $hash->{helper}{4}{telegramWait}{$messagePartCntr} = 1;
  5265. Log3 $name, 3, "EnOcean $name EnOcean_Set timeProgram" . $messagePartCntr . " set";
  5266. }
  5267. }
  5268. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 528, 0);
  5269. Log3 $name, 3, "EnOcean set $name $cmd";
  5270. } elsif ($cmd eq "deleteTimeProgram") {
  5271. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 512, 0);
  5272. Log3 $name, 3, "EnOcean set $name $cmd";
  5273. } elsif ($cmd eq "time") {
  5274. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 4, 0);
  5275. Log3 $name, 3, "EnOcean set $name $cmd";
  5276. } elsif ($cmd eq "window") {
  5277. if (defined $a[1]) {
  5278. if ($a[1] =~ m/^closed|open$/) {
  5279. readingsSingleUpdate($hash, "window", $a[1], 1);
  5280. readingsSingleUpdate($hash, "windowSet", $a[1], 0);
  5281. Log3 $name, 3, "EnOcean set $name window $a[1]";
  5282. shift(@a);
  5283. readingsSingleUpdate($hash, "waitingCmds", ReadingsVal($name, "waitingCmds", 0) | 2, 0);
  5284. } else {
  5285. return "Usage: $a[1] is wrong.";
  5286. }
  5287. }
  5288. } elsif ($cmd eq "clearCmds") {
  5289. CommandDeleteReading(undef, "$name waitingCmds");
  5290. Log3 $name, 3, "EnOcean set $name $cmd";
  5291. } else {
  5292. $cmdList .= "cooling:auto,off,on,no_change desired-temp setpointTemp:slider,0,1,40 " .
  5293. "comfortTemp deleteTimeProgram:noArg " .
  5294. "economyTemp preComfortTemp buildingProtectionTemp config:noArg " .
  5295. "clearCmds:noArg fanSpeed:slider,0,1,100 heating:auto,off,on,no_change " .
  5296. "fanSpeedMode:central,local time:noArg " .
  5297. "roomCtrlMode:comfort,economy,preComfort,buildingProtection timeProgram:noArg window:closed,open";
  5298. return "Unknown argument $cmd, choose one of $cmdList";
  5299. }
  5300. } elsif ($st eq "roomCtrlPanel.01") {
  5301. # Room Control Panel
  5302. # (D2-11-01 - D2-11-08)
  5303. $rorg = "D2";
  5304. $updateState = 0;
  5305. my $cooling = ReadingsVal($name, "colling", 'off');
  5306. my $fanSpeed = ReadingsVal($name, "fanSpeed", 'auto');
  5307. my $heating = ReadingsVal($name, "heating", 'off');
  5308. my $humidity = ReadingsVal($name, "humidity", 0);
  5309. my $occupancy = ReadingsVal($name, "occupancy", 'unoccupied');
  5310. my $setpointBase = ReadingsVal($name, "setpointBase", 20);
  5311. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  5312. my $setpointShift = ReadingsVal($name, "setpointShift", 0);
  5313. my $setpointShiftMax = ReadingsVal($name, "setpointShiftMax", 10);
  5314. my $setpointType = ReadingsVal($name, "setpointType", 'setpointShift');
  5315. my $temperature = ReadingsVal($name, "temperature", 20);
  5316. my $waitingCmds = ReadingsVal($name, "waitingCmds", 0);
  5317. my $window = ReadingsVal($name, "window", 'closed');
  5318. if ($cmd eq "desired-temp"|| $cmd eq "setpointTemp") {
  5319. if (defined $a[1]) {
  5320. if ($a[1] =~ m/^\d+$/ && $a[1] >= 5 && $a[1] <= 40) {
  5321. readingsBeginUpdate($hash);
  5322. if ($a[1] < 15) {
  5323. $setpointBase = 15;
  5324. $setpointShift = $a[1] - $setpointBase;
  5325. $setpointShiftMax = $setpointBase - $a[1] if ($setpointShiftMax < -$setpointShift);
  5326. readingsBulkUpdate($hash, "setpointShiftMax", $setpointShiftMax);
  5327. } elsif ($a[1] > 30) {
  5328. $setpointBase = 30;
  5329. $setpointShift = $a[1] - $setpointBase;
  5330. $setpointShiftMax = $a[1] - $setpointBase if ($setpointShiftMax < $setpointShift);
  5331. readingsBulkUpdate($hash, "setpointShiftMax", $setpointShiftMax);
  5332. } else {
  5333. $setpointBase = $a[1];
  5334. $setpointShift = 0;
  5335. }
  5336. readingsBulkUpdate($hash, "setpointShift", $setpointShift);
  5337. readingsBulkUpdate($hash, "setpointBase", $setpointBase);
  5338. $setpointTemp = $a[1];
  5339. readingsBulkUpdate($hash, "setpointTemp", $a[1]);
  5340. readingsBulkUpdate($hash, "state", "T: $temperature H: $humidity SPT: $setpointTemp F: $fanSpeed");
  5341. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 1);
  5342. readingsEndUpdate($hash, 1);
  5343. CommandDeleteReading(undef, "$name smartAckMailbox");
  5344. Log3 $name, 3, "EnOcean set $name setpointTemp $a[1]";
  5345. shift(@a);
  5346. } else {
  5347. return "Usage: $a[1] is not numeric or out of range";
  5348. }
  5349. } else {
  5350. return "Usage: set <name> setpointTemp 5...40";
  5351. }
  5352. } elsif ($cmd eq "setpointShiftMax") {
  5353. if (defined $a[1]) {
  5354. if ($a[1] =~ m/^\d+$/ && $a[1] >= 1 && $a[1] <= 10) {
  5355. readingsBeginUpdate($hash);
  5356. if ($setpointTemp < 15 - $a[1]) {
  5357. $setpointShiftMax = 15 - $setpointTemp;
  5358. } elsif ($setpointTemp > 30 + $a[1]) {
  5359. $setpointShiftMax = $setpointTemp - 30;
  5360. } else {
  5361. $setpointShiftMax = $a[1];
  5362. }
  5363. readingsBulkUpdate($hash, "setpointShiftMax", $setpointShiftMax);
  5364. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 2);
  5365. readingsEndUpdate($hash, 1);
  5366. CommandDeleteReading(undef, "$name smartAckMailbox");
  5367. Log3 $name, 3, "EnOcean set $name setpointShiftMax $a[1]";
  5368. shift(@a);
  5369. } else {
  5370. return "Usage: $a[1] is not numeric or out of range";
  5371. }
  5372. } else {
  5373. return "Usage: set <name> setpointShiftMax 1...10";
  5374. }
  5375. } elsif ($cmd eq "setpointType") {
  5376. if (defined $a[1]) {
  5377. if ($a[1] =~ m/^setpointTemp|setpointShift$/) {
  5378. readingsBeginUpdate($hash);
  5379. $setpointType = $a[1];
  5380. readingsBulkUpdate($hash, "setpointType", $setpointType);
  5381. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x80);
  5382. readingsEndUpdate($hash, 1);
  5383. CommandDeleteReading(undef, "$name smartAckMailbox");
  5384. Log3 $name, 3, "EnOcean set $name setpointType $a[1]";
  5385. shift(@a);
  5386. } else {
  5387. return "Usage: $a[1] is wrong.";
  5388. }
  5389. } else {
  5390. return "Usage: set <name> setpointType setpointTemp|setpointShift";
  5391. }
  5392. } elsif ($cmd eq 'fanSpeed') {
  5393. if (defined $a[1]) {
  5394. if ($a[1] =~ m/^auto|off|1|2|3$/) {
  5395. $fanSpeed = $a[1];
  5396. readingsBeginUpdate($hash);
  5397. readingsBulkUpdate($hash, "fanSpeed", $a[1]);
  5398. readingsBulkUpdate($hash, "state", "T: $temperature H: $humidity SPT: $setpointTemp F: $fanSpeed");
  5399. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 4);
  5400. readingsEndUpdate($hash, 1);
  5401. CommandDeleteReading(undef, "$name smartAckMailbox");
  5402. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5403. shift(@a);
  5404. } else {
  5405. return "Usage: $a[1] is wrong.";
  5406. }
  5407. } else {
  5408. return "Usage: set <name> fanspeed 1...3|auto|off";
  5409. }
  5410. } elsif ($cmd eq "cooling") {
  5411. if (defined $a[1]) {
  5412. if ($a[1] =~ m/^on|off$/) {
  5413. $cooling = $a[1];
  5414. readingsBeginUpdate($hash);
  5415. readingsBulkUpdate($hash, "cooling", $a[1]);
  5416. if ($a[1] eq 'on') {
  5417. $heating = 'off';
  5418. readingsBulkUpdate($hash, "heating", 'off');
  5419. }
  5420. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x20);
  5421. readingsEndUpdate($hash, 1);
  5422. CommandDeleteReading(undef, "$name smartAckMailbox");
  5423. Log3 $name, 3, "EnOcean set $name cooling $a[1]";
  5424. shift(@a);
  5425. } else {
  5426. return "Usage: $a[1] is wrong.";
  5427. }
  5428. } else {
  5429. return "Usage: set <name> cooling on|off";
  5430. }
  5431. } elsif ($cmd eq "heating") {
  5432. if (defined $a[1]) {
  5433. if ($a[1] =~ m/^on|off$/) {
  5434. $heating = $a[1];
  5435. readingsBeginUpdate($hash);
  5436. readingsBulkUpdate($hash, "heating", $a[1]);
  5437. if ($a[1] eq 'on') {
  5438. $cooling = 'off';
  5439. readingsBulkUpdate($hash, "cooling", 'off');
  5440. }
  5441. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x40);
  5442. readingsEndUpdate($hash, 1);
  5443. CommandDeleteReading(undef, "$name smartAckMailbox");
  5444. Log3 $name, 3, "EnOcean set $name heating $a[1]";
  5445. shift(@a);
  5446. } else {
  5447. return "Usage: $a[1] is wrong.";
  5448. }
  5449. } else {
  5450. return "Usage: set <name> heating on|off";
  5451. }
  5452. } elsif ($cmd eq "occupancy") {
  5453. if (defined $a[1]) {
  5454. if ($a[1] =~ m/^occupied|unoccupied$/) {
  5455. $occupancy = $a[1];
  5456. readingsBeginUpdate($hash);
  5457. readingsBulkUpdate($hash, "occupancy", $a[1]);
  5458. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 8);
  5459. readingsEndUpdate($hash, 1);
  5460. CommandDeleteReading(undef, "$name smartAckMailbox");
  5461. Log3 $name, 3, "EnOcean set $name occupancy $a[1]";
  5462. shift(@a);
  5463. } else {
  5464. return "Usage: $a[1] is wrong.";
  5465. }
  5466. } else {
  5467. return "Usage: set <name> occupancy occupied|unoccupied";
  5468. }
  5469. } elsif ($cmd eq "window") {
  5470. if (defined $a[1]) {
  5471. if ($a[1] =~ m/^closed|open$/) {
  5472. $window = $a[1];
  5473. readingsBeginUpdate($hash);
  5474. readingsBulkUpdate($hash, "window", $a[1]);
  5475. readingsBulkUpdate($hash, "waitingCmds", $waitingCmds |= 0x10);
  5476. readingsEndUpdate($hash, 1);
  5477. CommandDeleteReading(undef, "$name smartAckMailbox");
  5478. Log3 $name, 3, "EnOcean set $name window $a[1]";
  5479. shift(@a);
  5480. } else {
  5481. return "Usage: $a[1] is wrong.";
  5482. }
  5483. } else {
  5484. return "Usage: set <name> window open|closed";
  5485. }
  5486. } else {
  5487. $cmdList .= "setpointTemp:slider,5,1,40 cooling:off,on desired-temp " .
  5488. "fanSpeed:auto,off,1,2,3 heating:off,on occupancy:occupied,unoccupied " .
  5489. "setpointShiftMax:slider,1,1,10 setpointType:setpointShift,setpointTemp window:closed,open";
  5490. return "Unknown argument $cmd, choose one of $cmdList";
  5491. }
  5492. $setpointType = $setpointType eq 'setpointTemp' ? 0x80 : 0;
  5493. $heating = $heating eq 'on' ? 0x40 : 0;
  5494. $cooling = $cooling eq 'on' ? 0x20 : 0;
  5495. $window = $window eq 'open' ? 0x10 : 0;
  5496. $setpointShift = int(($setpointShift + $setpointShiftMax) * 255 / ($setpointShiftMax * 2));
  5497. #$setpointShift = unpack('C', pack('c', $setpointShift));
  5498. my %fanSpeed = ('auto' => 0, 'off' =>1, 1 => 2, 2 => 3, 3 => 4);
  5499. $occupancy = $occupancy eq 'occupied' ? 1 : 0;
  5500. $data = sprintf "%02X%02X%02X%02X", $setpointType |$heating | $cooling | $window | 1,
  5501. $setpointShift, $setpointBase,
  5502. $setpointShiftMax << 4 | $fanSpeed{$fanSpeed} << 1 | $occupancy;
  5503. } elsif ($st eq "fanCtrl.00") {
  5504. # Fan Control
  5505. # (D2-20-00 - D2-20-02)
  5506. $rorg = "D2";
  5507. #$updateState = 0;
  5508. my ($fanSpeed, $humiThreshold, $roomSize, $roomSizeRef, $humidityCtrl, $tempLevel, $opMode) =
  5509. (255, 255, 15, 3, 3, 3, 15);
  5510. my $messageType = 0;
  5511. my @roomSizeTbl = (25, 50, 75, 100, 125, 150, 175, 200, 225, 250, 275, 300, 325, 350);
  5512. if ($cmd eq "fanSpeed") {
  5513. $updateState = 0;
  5514. if (defined $a[1]) {
  5515. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  5516. $fanSpeed = $a[1];
  5517. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5518. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5519. shift(@a);
  5520. } elsif ($a[1] eq "auto") {
  5521. $fanSpeed = 253;
  5522. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5523. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5524. shift(@a);
  5525. } elsif ($a[1] eq "default") {
  5526. $fanSpeed = 254;
  5527. readingsSingleUpdate($hash, "fanSpeed", $a[1], 1);
  5528. Log3 $name, 3, "EnOcean set $name fanSpeed $a[1]";
  5529. shift(@a);
  5530. } else {
  5531. return "Usage: $a[1] is wrong.";
  5532. }
  5533. } else {
  5534. return "Usage: set <name> fanspeed 0...100|auto|default";
  5535. }
  5536. shift(@a);
  5537. } elsif ($cmd eq "on") {
  5538. $opMode = 1;
  5539. Log3 $name, 3, "EnOcean set $name $a[0]";
  5540. shift(@a);
  5541. } elsif ($cmd eq "off") {
  5542. $opMode = 0;
  5543. Log3 $name, 3, "EnOcean set $name $a[0]";
  5544. shift(@a);
  5545. } elsif ($cmd eq "desired-temp" || $cmd eq "setpointTemp") {
  5546. $updateState = 0;
  5547. my $temperatureRefDev = AttrVal($name, "temperatureRefDev", undef);
  5548. return "attribute missing: attr $name temperatureRefDev <refDev> must be defined" if (!defined $temperatureRefDev);
  5549. my $temperature = ReadingsVal($temperatureRefDev, "temperature", 20);
  5550. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  5551. my $switchHysteresis = AttrVal($name, "switchHysteresis", 1);
  5552. if (defined $a[1] && $a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 40) {
  5553. $setpointTemp = $a[1];
  5554. shift(@a);
  5555. }
  5556. if ($setpointTemp > $temperature + $switchHysteresis / 2) {
  5557. $tempLevel = 2;
  5558. } elsif ($setpointTemp < $temperature - $switchHysteresis / 2) {
  5559. $tempLevel = 0;
  5560. } else {
  5561. $tempLevel = 1;
  5562. }
  5563. readingsBeginUpdate($hash);
  5564. readingsBulkUpdate($hash, "setpointTemp", sprintf("%.1f", $setpointTemp));
  5565. readingsBulkUpdate($hash, "temperature", sprintf("%.1f", $temperature));
  5566. readingsEndUpdate($hash, 1);
  5567. Log3 $name, 3, "EnOcean set $name $cmd $setpointTemp";
  5568. shift(@a);
  5569. } elsif ($cmd eq "humidityThreshold") {
  5570. $updateState = 0;
  5571. if (defined $a[1]) {
  5572. if ($a[1] =~ m/^\d+$/ && $a[1] >= 0 && $a[1] <= 100) {
  5573. $humidityCtrl = 1;
  5574. $humiThreshold = $a[1];
  5575. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5576. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5577. shift(@a);
  5578. } elsif ($a[1] eq "auto") {
  5579. $humidityCtrl = 1;
  5580. $humiThreshold = 253;
  5581. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5582. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5583. shift(@a);
  5584. } elsif ($a[1] eq "default") {
  5585. $humidityCtrl = 2;
  5586. $humiThreshold = 254;
  5587. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5588. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5589. shift(@a);
  5590. } elsif ($a[1] eq "disabled") {
  5591. $humidityCtrl = 0;
  5592. $humiThreshold = 255;
  5593. readingsSingleUpdate($hash, "humidityThreshold", $a[1], 1);
  5594. Log3 $name, 3, "EnOcean set $name humidityThreshold $a[1]";
  5595. shift(@a);
  5596. } else {
  5597. return "Usage: $a[1] is wrong.";
  5598. }
  5599. } else {
  5600. return "Usage: set <name> humidityThreshold 0...100|auto|default|disabled";
  5601. }
  5602. shift(@a);
  5603. } elsif ($cmd eq "roomSize") {
  5604. $updateState = 0;
  5605. if (defined $a[1]) {
  5606. if ($a[1] =~ m/^\d+$/) {
  5607. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5608. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5609. $roomSize = 14;
  5610. for (my $i = 0; $i < @roomSizeTbl; $i++) {
  5611. if ($a[1] <= $roomSizeTbl[$i]) {
  5612. $roomSize = $i;
  5613. last;
  5614. }
  5615. }
  5616. $roomSizeRef = 0;
  5617. shift(@a);
  5618. } elsif ($a[1] eq "not_used") {
  5619. $roomSizeRef = 1;
  5620. $roomSize = 15;
  5621. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5622. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5623. shift(@a);
  5624. } elsif ($a[1] eq "default") {
  5625. $roomSizeRef = 2;
  5626. $roomSize = 15;
  5627. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5628. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5629. shift(@a);
  5630. } elsif ($a[1] eq "max") {
  5631. $roomSizeRef = 0;
  5632. $roomSize = 14;
  5633. readingsSingleUpdate($hash, "roomSize", $a[1], 1);
  5634. Log3 $name, 3, "EnOcean set $name roomSize $a[1]";
  5635. shift(@a);
  5636. } else {
  5637. return "Usage: $a[1] is wrong.";
  5638. }
  5639. } else {
  5640. return "Usage: set <name> roomSize 0...350|max|not_used|default";
  5641. }
  5642. shift(@a);
  5643. } else {
  5644. $cmdList .= "off:noArg on:noArg desired-temp fanSpeed setpointTemp:slider,0,1,40 " .
  5645. "humidityThreshold roomSize";
  5646. return "Unknown argument $cmd, choose one of $cmdList";
  5647. }
  5648. $data = sprintf "%02X%02X%02X%02X", ($opMode << 4) | ($tempLevel << 1),
  5649. ($humidityCtrl << 6) | ($roomSizeRef << 4) | $roomSize,
  5650. $humiThreshold, $fanSpeed;
  5651. } elsif ($st eq "heatRecovery.00") {
  5652. # heat recovery ventilation
  5653. # (D2-50-00)
  5654. $rorg = "D2";
  5655. $updateState = 0;
  5656. my $airQuatityThreshold = ReadingsVal($name, "airQuatityThreshold", 'default');
  5657. $airQuatityThreshold = $airQuatityThreshold eq 'default' ? 127 : $airQuatityThreshold;
  5658. my $CO2Threshold = ReadingsVal($name, "CO2Threshold", 'default');
  5659. $CO2Threshold = $CO2Threshold eq 'default' ? 127 : $CO2Threshold;
  5660. my $heatExchangerBypass = 0;
  5661. my $humidityThreshold = ReadingsVal($name, "humidityThreshold", 'default');
  5662. $humidityThreshold = $humidityThreshold eq 'default' ? 127 : $humidityThreshold;
  5663. my $startTimerMode = 0;
  5664. my $tempThreshold = ReadingsVal($name, "roomTempSet", 'default');;
  5665. $tempThreshold = $tempThreshold eq 'default' ? 127 : $tempThreshold;
  5666. my $ventilation = 15;
  5667. if ($cmd eq "ventilation") {
  5668. $ventilation = $a[1];
  5669. return "Usage: $cmd variable is missing, choose off|1...4|auto|demand|supplyAir|exhaustAir." if (!defined $ventilation);
  5670. shift(@a);
  5671. my %ventilation = (
  5672. "off" => 0,
  5673. 1 => 1,
  5674. 2 => 2,
  5675. 3 => 3,
  5676. 4 => 4,
  5677. "auto" => 11,
  5678. "demand" => 12,
  5679. "supplyAir" => 13,
  5680. "exhaustAir" => 14
  5681. );
  5682. if (exists $ventilation{$ventilation}) {
  5683. $ventilation = $ventilation{$ventilation};
  5684. } else {
  5685. return "Usage: $cmd variable wrong, choose off|1...4|auto|demand|supplyAir|exhaustAir.";
  5686. }
  5687. } elsif ($cmd eq "heatExchangerBypass") {
  5688. $heatExchangerBypass = $a[1];
  5689. return "Usage: $cmd variable is missing, choose opens|closes." if (!defined $heatExchangerBypass);
  5690. shift(@a);
  5691. my %heatExchangerBypass = (
  5692. "closes" => 1,
  5693. "opens" => 2
  5694. );
  5695. if (exists $heatExchangerBypass{$heatExchangerBypass}) {
  5696. $heatExchangerBypass = $heatExchangerBypass{$heatExchangerBypass};
  5697. } else {
  5698. return "Usage: $cmd variable wrong, choose opens|closes.";
  5699. }
  5700. } elsif ($cmd eq "startTimerMode") {
  5701. $startTimerMode = 1;
  5702. } elsif ($cmd eq "CO2Threshold") {
  5703. $CO2Threshold = $a[1];
  5704. if (defined $CO2Threshold) {
  5705. if ($CO2Threshold eq 'default') {
  5706. $CO2Threshold = 127;
  5707. readingsSingleUpdate($hash, "CO2Threshold", 'default', 1);
  5708. } elsif ($CO2Threshold =~ m/^\d+$/ && $CO2Threshold >= 0 && $CO2Threshold <= 100) {
  5709. readingsSingleUpdate($hash, "CO2Threshold", $CO2Threshold, 1);
  5710. } else {
  5711. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5712. }
  5713. } else {
  5714. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5715. }
  5716. shift(@a);
  5717. } elsif ($cmd eq "humidityThreshold") {
  5718. $humidityThreshold = $a[1];
  5719. if (defined $humidityThreshold) {
  5720. if ($humidityThreshold eq 'default') {
  5721. $humidityThreshold = 127;
  5722. readingsSingleUpdate($hash, "humidityThreshold", 'default', 1);
  5723. } elsif ($humidityThreshold =~ m/^\d+$/ && $humidityThreshold >= 0 && $humidityThreshold <= 100) {
  5724. readingsSingleUpdate($hash, "humidityThreshold", $humidityThreshold, 1);
  5725. } else {
  5726. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5727. }
  5728. } else {
  5729. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5730. }
  5731. shift(@a);
  5732. } elsif ($cmd eq "airQuatityThreshold") {
  5733. $airQuatityThreshold = $a[1];
  5734. if (defined $airQuatityThreshold) {
  5735. if ($airQuatityThreshold eq 'default') {
  5736. $airQuatityThreshold = 127;
  5737. readingsSingleUpdate($hash, "airQuatityThreshold", 'default', 1);
  5738. } elsif ($airQuatityThreshold =~ m/^\d+$/ && $airQuatityThreshold >= 0 && $airQuatityThreshold <= 100) {
  5739. readingsSingleUpdate($hash, "airQuatityThreshold", $airQuatityThreshold, 1);
  5740. } else {
  5741. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5742. }
  5743. } else {
  5744. return "Usage: $cmd variable is wrong, choose default|0 ... 100." ;
  5745. }
  5746. shift(@a);
  5747. } elsif ($cmd eq "roomTemp") {
  5748. $tempThreshold = $a[1];
  5749. if (defined $tempThreshold) {
  5750. if ($tempThreshold eq 'default') {
  5751. $tempThreshold = 127;
  5752. readingsSingleUpdate($hash, "roomTempSet", 'default', 1);
  5753. } elsif ($tempThreshold =~ m/^[+-]?\d+$/ && $tempThreshold >= - 63 && $tempThreshold <= 63) {
  5754. readingsSingleUpdate($hash, "roomTempSet", $tempThreshold, 1);
  5755. $tempThreshold = abs($tempThreshold) | 0x40 if ($tempThreshold < 0);
  5756. } else {
  5757. return "Usage: $cmd variable is wrong, choose default|-63 ... 63." ;
  5758. }
  5759. } else {
  5760. return "Usage: $cmd variable is wrong, choose default|-63 ... 63." ;
  5761. }
  5762. shift(@a);
  5763. } else {
  5764. $cmdList .= "ventilation:off,1,2,3,4,auto,demand,supplyAir,exhaustAir roomTemp heatExchangerBypass:closes,opens " .
  5765. "startTimerMode:noArg CO2Threshold humidityThreshold airQuatityThreshold";
  5766. return "Unknown argument $cmd, choose one of $cmdList";
  5767. }
  5768. $data = sprintf "%02X%02X%02X%02X%02X%02X", 32 | $ventilation, $heatExchangerBypass << 4, $startTimerMode << 7 | $CO2Threshold,
  5769. $humidityThreshold, $airQuatityThreshold, $tempThreshold;
  5770. Log3 $name, 3, "EnOcean set $name $cmd";
  5771. } elsif ($st eq "valveCtrl.00") {
  5772. # Valve Control
  5773. # (D2-A0-01)
  5774. if (AttrVal($name, "devMode", "master") eq "slave") {
  5775. # devNode slave
  5776. if ($cmd eq "closed") {
  5777. $rorg = "D2";
  5778. $data = "01";
  5779. } elsif ($cmd eq "open") {
  5780. $rorg = "D2";
  5781. $data = "02";
  5782. } elsif ($cmd eq "teachIn") {
  5783. $updateState = 0;
  5784. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, "biDir",
  5785. AttrVal($name, "uteResponseRequest", "yes"), "in", 0, "D2-A0-01");
  5786. } elsif ($cmd eq "teachOut") {
  5787. $updateState = 0;
  5788. ($err, $rorg, $data) = EnOcean_sndUTE(undef, $hash, "biDir",
  5789. AttrVal($name, "uteResponseRequest", "yes"), "out", 0, "D2-A0-01");
  5790. } else {
  5791. return "Unknown argument $cmd, choose one of " . $cmdList . "open:noArg closed:noArg teachIn:noArg teachOut:noArg";
  5792. }
  5793. } else {
  5794. # devMode master
  5795. if ($cmd eq "closes") {
  5796. $rorg = "D2";
  5797. $data = "01";
  5798. } elsif ($cmd eq "opens") {
  5799. $rorg = "D2";
  5800. $data = "02";
  5801. } else {
  5802. return "Unknown argument $cmd, choose one of " . $cmdList . "opens:noArg closes:noArg";
  5803. }
  5804. }
  5805. Log3 $name, 3, "EnOcean set $name $cmd";
  5806. } elsif ($st eq "contact") {
  5807. # 1BS Telegram
  5808. # Single Input Contact (EEP D5-00-01)
  5809. $rorg = "D5";
  5810. my $setCmd;
  5811. if ($cmd eq "teach") {
  5812. $attr{$name}{eep} = "D5-00-01";
  5813. CommandDeleteReading(undef, "$name .*");
  5814. readingsSingleUpdate($hash, "teach", "1BS teach-in sent", 1);
  5815. $setCmd = 0;
  5816. $updateState = 0;
  5817. } elsif ($cmd eq "closed") {
  5818. $setCmd = 9;
  5819. } elsif ($cmd eq "open") {
  5820. $setCmd = 8;
  5821. } else {
  5822. return "Unknown argument $cmd, choose one of " . $cmdList . "open:noArg closed:noArg teach:noArg";
  5823. }
  5824. $data = sprintf "%02X", $setCmd;
  5825. Log3 $name, 3, "EnOcean set $name $cmd";
  5826. } elsif ($st eq "genericProfile") {
  5827. # Generic Profile
  5828. my $channel = 0;
  5829. my $devMode = AttrVal($name, "devMode", "master");
  5830. my $header = 1;
  5831. my ($setChannel, $setChannelName) = split(/-|:/, $cmd, 2);
  5832. my ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax);
  5833. my ($readingFormat, $readingName, $readingType, $readingUnit, $readingValue);
  5834. my $gpDef = AttrVal($name, "gpDef", undef);
  5835. return "Usage: Channel definition is missing" if (!defined $gpDef);
  5836. my @gpDef = split("[ \t][ \t]*", $gpDef);
  5837. if ($cmd eq "channelName") {
  5838. # rename channel name
  5839. ($setChannel, $setChannelName) = split(/-|:/, $a[1], 2);
  5840. if (defined $gpDef[$setChannel]) {
  5841. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  5842. split(':', $gpDef[$setChannel]);
  5843. # remove spaces und tabs
  5844. #$channelName =~ tr/ \t//d;
  5845. if ($setChannelName eq "?") {
  5846. $channelName = "none";
  5847. if ($channelType == 1 && defined $EnO_gpValueData{$signalType}{name}) {
  5848. $channelName = $EnO_gpValueData{$signalType}{name};
  5849. } elsif ($channelType == 2 && defined $EnO_gpValueFlag{$signalType}{name}) {
  5850. $channelName = $EnO_gpValueFlag{$signalType}{name};
  5851. } elsif ($channelType == 3 && defined $EnO_gpValueEnum{$signalType}{name}) {
  5852. $channelName = $EnO_gpValueEnum{$signalType}{name};
  5853. }
  5854. } else {
  5855. $channelName = $setChannelName;
  5856. }
  5857. $resolution = '' if (!defined $resolution);
  5858. $engMin = '' if (!defined $engMin);
  5859. $scalingMin = '' if (!defined $scalingMin);
  5860. $engMax = '' if (!defined $engMax);
  5861. $scalingMax = '' if (!defined $scalingMax);
  5862. $gpDef[$setChannel] = $channelName . ':' . $channelDir . ':' . $channelType . ':' . $signalType . ':' . $valueType .
  5863. ':' . $resolution . ':' . $engMin . ':' . $scalingMin . ':' . $engMax . ':' . $scalingMax;
  5864. $attr{$name}{gpDef} = join(' ', @gpDef);
  5865. shift @a;
  5866. $updateState = 3;
  5867. $channelType = 255;
  5868. EnOcean_CommandSave(undef, undef);
  5869. } else {
  5870. return "Wrong parameter, channel $setChannel not defined.";
  5871. }
  5872. } elsif ($cmd eq "teachIn" && $devMode eq "slave") {
  5873. # teach-in generic profile
  5874. $rorg = "B0";
  5875. my ($gpDefO, $gpDefI, $formatPattern, $teachInInfo);
  5876. my $channelDirSeq = "--";
  5877. my $comMode = 0;
  5878. $attr{$name}{comMode} = "uniDir";
  5879. $attr{$name}{eep} = "B0-00-00";
  5880. # multicast teach-in
  5881. $destinationID = "FFFFFFFF";
  5882. my $productID = AttrVal($name, "productID", undef);
  5883. if (defined $productID) {
  5884. $productID = '0000000010' . EnOcean_convHexToBit($productID);
  5885. } else {
  5886. $productID = '';
  5887. }
  5888. while ($gpDef[$channel]) {
  5889. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  5890. split(':', $gpDef[$channel]);
  5891. if ($channelDir eq "O") {
  5892. #Log3 $name, 3, "EnOcean set $name channel: $channel channelDir: $channelDir seq: $channelDirSeq";
  5893. #Log3 $name, 3, "EnOcean set $name channel: $channel channelType: $channelType signalType: $signalType valueType: $valueType";
  5894. return "Usage: attr $name gpDef: O/I sequence error" if $channelDirSeq =~ m/.I$/;
  5895. $channelDirSeq = "O-";
  5896. # add channel-, signal- and valuetype
  5897. $gpDefO .= substr(unpack('B8', pack('C', $channelType)), 6) .
  5898. unpack('B8', pack('C', $signalType)) .
  5899. substr(unpack('B8', pack('C', $valueType)), 6);
  5900. if ($channelType == 1 || $channelType == 3) {
  5901. # data, enumeration: add resolution
  5902. $gpDefO .= substr(unpack('B8', pack('C', $resolution)), 4);
  5903. }
  5904. if ($channelType == 1) {
  5905. # data: add engineering and scaling
  5906. $gpDefO .= unpack('B8', pack('c', $engMin)) .
  5907. substr(unpack('B8', pack('C', $scalingMin)), 4) .
  5908. unpack('B8', pack('c', $engMax)) .
  5909. substr(unpack('B8', pack('C', $scalingMax)), 4);
  5910. }
  5911. } elsif ($channelDir eq "I") {
  5912. #Log3 $name, 3, "EnOcean set $name channel: $channel channelDir: $channelDir seq: $channelDirSeq";
  5913. return "Usage: attr $name gpDef: O/I sequence error" if $channelDirSeq !~ m/^O./;
  5914. $channelDirSeq = "OI";
  5915. $gpDefI .= substr(unpack('B8', pack('C', $channelType)), 6) .
  5916. unpack('B8', pack('C', $signalType)) .
  5917. substr(unpack('B8', pack('C', $valueType)), 6);
  5918. if ($channelType == 1 || $channelType == 3) {
  5919. # data, enumeration: add resolution
  5920. $gpDefI .= substr(unpack('B8', pack('C', $resolution)), 4);
  5921. }
  5922. if ($channelType == 1) {
  5923. # data: add engineering and scaling
  5924. $gpDefI .= unpack('B8', pack('c', $engMin)) .
  5925. substr(unpack('B8', pack('C', $scalingMin)), 4) .
  5926. unpack('B8', pack('c', $engMax)) .
  5927. substr(unpack('B8', pack('C', $scalingMax)), 4);
  5928. }
  5929. }
  5930. $channel ++;
  5931. }
  5932. if ($channelDirSeq eq "OI") {
  5933. # await teach-in response
  5934. $comMode = 1;
  5935. $attr{$name}{comMode} = "biDir";
  5936. # set flag for response request
  5937. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{teachInReq} = "in";
  5938. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{hash} = $hash;
  5939. if (!exists($hash->{IODev}{Teach})) {
  5940. # enable teach-in receiving for 3 sec
  5941. $hash->{IODev}{Teach} = 1;
  5942. my %timeoutHash = (hash => $IOHash, function => "gpRespTimeout", helper => "gpRespWait");
  5943. RemoveInternalTimer(\%timeoutHash);
  5944. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  5945. }
  5946. }
  5947. $header = (0x7FF << 1 | $comMode) << 4;
  5948. if ($channelDirSeq =~ m/.I$/) {
  5949. # create teach-in information
  5950. if (length($gpDefI) % 8) {
  5951. # fill with trailing zeroes to x bytes
  5952. $gpDefI .= 0 x (8 - length($gpDefI) % 8);
  5953. }
  5954. $teachInInfo = '0000000001' . unpack('B8', pack('C', length($gpDefI) / 4));
  5955. }
  5956. #Log3 $name, 3, "EnOcean set $name header: $header O: $gpDefO Info: $teachInInfo I: $gpDefI";
  5957. # DophinView GP profile error if Product ID sent
  5958. $data = $productID . $gpDefO . $teachInInfo . $gpDefI;
  5959. #$data = $gpDefO . $teachInInfo . $gpDefI;
  5960. if (length($data) % 8) {
  5961. # fill with trailing zeroes to x bytes
  5962. $data .= 0 x (8 - length($data) % 8);
  5963. }
  5964. $channelType = 0;
  5965. EnOcean_CommandSave(undef, undef);
  5966. $data = sprintf '%04X%s', $header, EnOcean_convBitToHex($data);
  5967. my $teachInState = $comMode == 1 ? "teach-in sent, response requested" : "teach-in sent";
  5968. readingsSingleUpdate($hash, "teach", "GP $teachInState", 1);
  5969. } elsif ($cmd eq "teachOut" && $devMode eq "slave") {
  5970. # teach out generic profile
  5971. $rorg = "B0";
  5972. $channelType = 0;
  5973. my $comMode = 0;
  5974. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  5975. $comMode = 1;
  5976. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{teachInReq} = "out";
  5977. $hash->{IODev}{helper}{gpRespWait}{AttrVal($name, "subDef", $hash->{DEF})}{hash} = $hash;
  5978. if (!exists($hash->{IODev}{Teach})) {
  5979. # enable teach-in receiving for 3 sec
  5980. $hash->{IODev}{Teach} = 1;
  5981. my %timeoutHash = (hash => $IOHash, function => "gpRespTimeout", helper => "gpRespWait");
  5982. RemoveInternalTimer(\%timeoutHash);
  5983. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  5984. }
  5985. }
  5986. $data = sprintf '%04X', (0x7FF << 1 | $comMode) << 4 | 4;
  5987. my $teachInState = $comMode == 1 ? "teach-in deletion sent, response requested" : "teach-in deletion sent";
  5988. readingsSingleUpdate($hash, "teach", "GP $teachInState", 1);
  5989. } elsif ($setChannel =~ m/^\d+$/ && defined $gpDef[$setChannel]) {
  5990. # send selective data (GPSD)
  5991. $rorg = "B3";
  5992. # select channel
  5993. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  5994. split(':', $gpDef[$setChannel]);
  5995. if ($channelName eq $setChannelName && $channelDir eq "O") {
  5996. $channel = $setChannel;
  5997. } else {
  5998. return "Channel name wrong or no output channel";
  5999. }
  6000. } else {
  6001. # command error
  6002. my $channelCntr = 0;
  6003. my @cmdList;
  6004. while (defined $gpDef[$channelCntr]) {
  6005. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  6006. split(':', $gpDef[$channelCntr]);
  6007. if ($channelDir ne "O") {
  6008. $channelCntr ++;
  6009. next;
  6010. }
  6011. if ($channelType == 1) {
  6012. # data
  6013. push @cmdList, sprintf('%02d', $channelCntr) . "-" . $channelName;
  6014. } elsif ($channelType == 2) {
  6015. # flag
  6016. push @cmdList, sprintf('%02d', $channelCntr) . "-" . $channelName . ':' .
  6017. $EnO_gpValueFlag{$signalType}{flag}{0} . "," .
  6018. $EnO_gpValueFlag{$signalType}{flag}{1};
  6019. } elsif ($channelType == 3) {
  6020. # enumeration
  6021. my $cmdListEnum = "";
  6022. my $enum = 0;
  6023. while (defined $EnO_gpValueEnum{$signalType}{enum}{$enum}) {
  6024. $cmdListEnum .= $EnO_gpValueEnum{$signalType}{enum}{$enum} . ",";
  6025. $enum ++;
  6026. }
  6027. push @cmdList, sprintf('%02d', $channelCntr) . "-" . $channelName . ':' . substr($cmdListEnum, 0, -1);
  6028. }
  6029. $channelCntr ++;
  6030. }
  6031. if (defined $cmdList[0] && $devMode eq "slave") {
  6032. return "Unknown argument $cmd, choose one of " . $cmdList . 'channelName teachIn:noArg teachOut:noArg ' . join(" ", @cmdList);
  6033. } elsif (defined $cmdList[0] && $devMode eq "master") {
  6034. return "Unknown argument $cmd, choose one of " . $cmdList . 'channelName ' . join(" ", @cmdList);
  6035. } else {
  6036. return "Unknown argument $cmd, choose one of " . $cmdList . 'channelName';
  6037. }
  6038. }
  6039. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel";
  6040. if ($channelType == 1) {
  6041. # data
  6042. if ($engMin * $EnO_scaling[$scalingMin] > $engMax * $EnO_scaling[$scalingMax]) {
  6043. return "Usage: numerical value is missing" if (!defined $a[1]);
  6044. if ($a[1] =~ m/^[-+]?\d*\.?\d+([eE][-+]?\d+)?$/ &&
  6045. $a[1] >= $engMax * $EnO_scaling[$scalingMax] &&
  6046. $a[1] <= $engMin * $EnO_scaling[$scalingMin]) {
  6047. $data = int(2**$EnO_resolution[$resolution] * ($a[1] - $engMin * $EnO_scaling[$scalingMin]) /
  6048. ($engMax * $EnO_scaling[$scalingMax] - $engMin * $EnO_scaling[$scalingMin]));
  6049. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6050. if ($data >= 2**$EnO_resolution[$resolution]) {
  6051. $data = 2**$EnO_resolution[$resolution] - 1;
  6052. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6053. }
  6054. shift @a;
  6055. } else {
  6056. return "Usage: $a[1] is not numeric or out of range";
  6057. }
  6058. } else {
  6059. return "Usage: numerical value is missing" if (!defined $a[1]);
  6060. if ($a[1] =~ m/^[-+]?\d*\.?\d+([eE][-+]?\d+)?$/ &&
  6061. $a[1] >= $engMin * $EnO_scaling[$scalingMin] &&
  6062. $a[1] <= $engMax * $EnO_scaling[$scalingMax]) {
  6063. $data = int(2**$EnO_resolution[$resolution] * ($a[1] - $engMin * $EnO_scaling[$scalingMin]) /
  6064. ($engMax * $EnO_scaling[$scalingMax] - $engMin * $EnO_scaling[$scalingMin]));
  6065. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6066. if ($data >= 2**$EnO_resolution[$resolution]) {
  6067. $data = 2**$EnO_resolution[$resolution] - 1;
  6068. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel resolution: " . $EnO_resolution[$resolution] . " data: $data";
  6069. }
  6070. shift @a;
  6071. } else {
  6072. return "Usage: $a[1] is not numeric or out of range";
  6073. }
  6074. }
  6075. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType) =
  6076. EnOcean_gpConvDataToValue (undef, $hash, $channel, $data, $gpDef[$channel]);
  6077. readingsBeginUpdate($hash);
  6078. readingsBulkUpdate($hash, $readingName, sprintf("$readingFormat", $readingValue));
  6079. readingsBulkUpdate($hash, $readingName . "Unit", $readingUnit);
  6080. readingsBulkUpdate($hash, $readingName . "ValueType", $valueType);
  6081. readingsBulkUpdate($hash, $readingName . "ChannelType", $readingType);
  6082. readingsEndUpdate($hash, 1);
  6083. $data = EnOcean_gpConvSelDataToSndData($header, $channel, $EnO_resolution[$resolution], $data);
  6084. } elsif ($channelType == 2) {
  6085. # flag
  6086. if (defined $EnO_gpValueFlag{$signalType}{flagInv}{$a[1]}) {
  6087. $data = $EnO_gpValueFlag{$signalType}{flagInv}{$a[1]};
  6088. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel data: " . $EnO_gpValueFlag{$signalType}{flagInv}{$a[1]};
  6089. shift @a;
  6090. } else {
  6091. return "Usage: $a[1] is unknown";
  6092. }
  6093. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel data: $data";
  6094. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType)=
  6095. EnOcean_gpConvDataToValue (undef, $hash, $channel, $data, $gpDef[$channel]);
  6096. readingsBeginUpdate($hash);
  6097. readingsBulkUpdate($hash, $readingName, sprintf("$readingFormat", $readingValue));
  6098. readingsBulkUpdate($hash, $readingName . "Unit", $readingUnit);
  6099. readingsBulkUpdate($hash, $readingName . "ValueType", $valueType);
  6100. readingsBulkUpdate($hash, $readingName . "ChannelType", $readingType);
  6101. readingsEndUpdate($hash, 1);
  6102. $data = sprintf '%04X', (($header << 6 | $channel) << 1 | $data) << 5;
  6103. } elsif ($channelType == 3) {
  6104. # enumeration
  6105. if (defined $EnO_gpValueEnum{$signalType}{enumInv}{$a[1]}) {
  6106. $data = $EnO_gpValueEnum{$signalType}{enumInv}{$a[1]};
  6107. #Log3 $name, 3, "EnOcean set $name header: $header channel: $channel data: $data";
  6108. shift @a;
  6109. } else {
  6110. return "Usage: $a[1] is unknown";
  6111. }
  6112. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType)=
  6113. EnOcean_gpConvDataToValue (undef, $hash, $channel, $data, $gpDef[$channel]);
  6114. readingsBeginUpdate($hash);
  6115. readingsBulkUpdate($hash, $readingName, sprintf("$readingFormat", $readingValue));
  6116. readingsBulkUpdate($hash, $readingName . "Unit", $readingUnit);
  6117. readingsBulkUpdate($hash, $readingName . "ValueType", $valueType);
  6118. readingsBulkUpdate($hash, $readingName . "ChannelType", $readingType);
  6119. readingsEndUpdate($hash, 1);
  6120. $data = EnOcean_gpConvSelDataToSndData($header, $channel, $EnO_resolution[$resolution], $data);
  6121. }
  6122. Log3 $name, 3, "EnOcean set $name $cmd";
  6123. } elsif ($st eq "raw") {
  6124. # sent raw data
  6125. if ($cmd eq "4BS"){
  6126. # 4BS Telegram
  6127. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{8}$/) {
  6128. $data = uc($a[1]);
  6129. $rorg = "A5";
  6130. } else {
  6131. return "Wrong parameter, choose 4BS <data 4 Byte hex> [status 1 Byte hex]";
  6132. }
  6133. } elsif ($cmd eq "1BS") {
  6134. # 1BS Telegram
  6135. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  6136. $data = uc($a[1]);
  6137. $rorg = "D5";
  6138. } else {
  6139. return "Wrong parameter, choose 1BS <data 1 Byte hex> [status 1 Byte hex]";
  6140. }
  6141. } elsif ($cmd eq "RPS") {
  6142. # RPS Telegram
  6143. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2}$/) {
  6144. $data = uc($a[1]);
  6145. $rorg = "F6";
  6146. } else {
  6147. return "Wrong parameter, choose RPS <data 1 Byte hex> [status 1 Byte hex]";
  6148. }
  6149. } elsif ($cmd eq "MSC") {
  6150. # MSC Telegram
  6151. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6152. $data = uc($a[1]);
  6153. $rorg = "D1";
  6154. } else {
  6155. return "Wrong parameter, choose MSC <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6156. }
  6157. } elsif ($cmd eq "UTE") {
  6158. # UTE Telegram
  6159. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{14}$/) {
  6160. $data = uc($a[1]);
  6161. $rorg = "D4";
  6162. } else {
  6163. return "Wrong parameter, choose UTE <data 7 Byte hex> [status 1 Byte hex]";
  6164. }
  6165. } elsif ($cmd eq "VLD") {
  6166. # VLD Telegram
  6167. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6168. $data = uc($a[1]);
  6169. $rorg = "D2";
  6170. } else {
  6171. return "Wrong parameter, choose VLD <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6172. }
  6173. } elsif ($cmd eq "GPTI") {
  6174. # GP teach-in request telegram
  6175. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6176. $data = uc($a[1]);
  6177. $rorg = "B0";
  6178. } else {
  6179. return "Wrong parameter, choose GPTI <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6180. }
  6181. } elsif ($cmd eq "GPTR") {
  6182. # GP teach-in response telegram
  6183. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6184. $data = uc($a[1]);
  6185. $rorg = "B1";
  6186. } else {
  6187. return "Wrong parameter, choose GPTR <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6188. }
  6189. } elsif ($cmd eq "GPCD") {
  6190. # GP complete date telegram
  6191. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6192. $data = uc($a[1]);
  6193. $rorg = "B2";
  6194. } else {
  6195. return "Wrong parameter, choose GPCD <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6196. }
  6197. } elsif ($cmd eq "GPSD") {
  6198. # GP selective data telegram
  6199. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,1024}$/ && !(length($a[1]) % 2)) {
  6200. $data = uc($a[1]);
  6201. $rorg = "B3";
  6202. } else {
  6203. return "Wrong parameter, choose GPSD <data 1 ... 512 Byte hex> [status 1 Byte hex]";
  6204. }
  6205. } elsif ($cmd eq "SEC") {
  6206. # secure telegram
  6207. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6208. $data = uc($a[1]);
  6209. $rorg = "30";
  6210. } else {
  6211. return "Wrong parameter, choose SEC <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6212. }
  6213. } elsif ($cmd eq "ENC") {
  6214. # secure telegram with encapsulation
  6215. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6216. $data = uc($a[1]);
  6217. $rorg = "31";
  6218. } else {
  6219. return "Wrong parameter, choose ENC <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6220. }
  6221. } elsif ($cmd eq "STE") {
  6222. # secure Teach-In
  6223. if ($a[1] && $a[1] =~ m/^[\dA-Fa-f]{2,28}$/ && !(length($a[1]) % 2)) {
  6224. $data = uc($a[1]);
  6225. $rorg = "35";
  6226. } else {
  6227. return "Wrong parameter, choose STE <data 1 ... 14 Byte hex> [status 1 Byte hex]";
  6228. }
  6229. } else {
  6230. return "Unknown argument $cmd, choose one of 1BS 4BS ENC GPCD GPSD GPTI GPTR MSC RPS SEC STE UTE VLD";
  6231. }
  6232. if ($a[2]) {
  6233. if ($a[2] !~ m/^[\dA-Fa-f]{2}$/) {
  6234. return "Wrong status parameter, choose $cmd $a[1] [status 1 Byte hex]";
  6235. }
  6236. $status = uc($a[2]);
  6237. splice(@a,2,1);
  6238. }
  6239. $updateState = 0;
  6240. readingsSingleUpdate($hash, "RORG", $cmd, 1);
  6241. readingsSingleUpdate($hash, "dataSent", $data, 1);
  6242. readingsSingleUpdate($hash, "statusSent", $status, 1);
  6243. Log3 $name, 3, "EnOcean set $name $cmd $data $status";
  6244. shift(@a);
  6245. } elsif ($st eq "remote") {
  6246. return "Unknown argument $cmd, choose one of $cmdList";
  6247. } else {
  6248. # subtype does not support set commands
  6249. $updateState = -1;
  6250. if (AttrVal($name, "remoteManagement", "off") eq "manager") {
  6251. return "Unknown argument $cmd, choose one of $cmdList";
  6252. } else {
  6253. return;
  6254. }
  6255. }
  6256. # set reading state if confirmation telegram is not expected
  6257. if($updateState == 1 && $updateStateAttr =~ m/^default|yes$/) {
  6258. readingsSingleUpdate($hash, "state", $cmd, 1);
  6259. } elsif ($updateState == 0 && $updateStateAttr eq "yes") {
  6260. readingsSingleUpdate($hash, "state", $cmd, 1);
  6261. #} elsif ($updateState == 3) {
  6262. #internal command
  6263. #} else {
  6264. # readingsSingleUpdate($hash, ".info", "await_confirm", 0);
  6265. }
  6266. # send commands
  6267. if($updateState >= -1 && $updateState <= 1) {
  6268. EnOcean_SndCdm(undef, $hash, $packetType, $rorg, $data, $subDef, $status, $destinationID);
  6269. EnOcean_observeInit(1, $hash, @cmdObserve);
  6270. if ($switchMode eq "pushbutton" && $cmd1 ne "released") {
  6271. my @timerCmd = ($name, "released");
  6272. my %par = (hash => $hash, timerCmd => \@timerCmd);
  6273. InternalTimer(gettimeofday() + 0.1, "EnOcean_TimerSet", \%par, 0);
  6274. }
  6275. }
  6276. #Log3 $name, 3, "EnOcean set $name remainder of CmdArg: " . join(' ' ,@a) if (@a > 0);
  6277. }
  6278. return undef;
  6279. }
  6280. # parse and display the incoming telegrams
  6281. sub EnOcean_Parse($$)
  6282. {
  6283. my ($iohash, $msg) = @_;
  6284. my $IODev = $iohash->{NAME};
  6285. my ($hash, $name, $filelogName, $rorgname);
  6286. my ($ctrl, $err, $logLevel, $response);
  6287. Log3 $IODev, 4, "EnOcean received via $IODev: $msg";
  6288. my @msg = split(':', $msg);
  6289. my ($rorg, $data, $senderID, $status, $odata, $subDef, $destinationID, $funcNumber, $manufID, $RSSI, $delay, $subTelNum);
  6290. my $packetType = hex($msg[1]);
  6291. my @event;
  6292. if ($packetType == 1) {
  6293. # packet type RADIO
  6294. #EnOcean:PacketType:RORG:MessageData:SourceID:Status:OptionalData
  6295. (undef, undef, $rorg, $data, $senderID, $status, $odata) = @msg;
  6296. $odata =~ m/^(..)(........)(..)(..)$/;
  6297. ($subTelNum, $destinationID, $RSSI) = (hex($1), $2, hex($3));
  6298. if (exists $modules{EnOcean}{defptr}{$senderID}) {
  6299. $hash = $modules{EnOcean}{defptr}{$senderID};
  6300. } elsif ($destinationID ne 'FFFFFFFF') {
  6301. $hash = $modules{EnOcean}{defptr}{$destinationID};
  6302. }
  6303. $rorgname = $EnO_rorgname{$rorg};
  6304. if (!$rorgname) {
  6305. if($hash) {
  6306. Log3 $hash->{NAME}, 2, "EnOcean $hash->{NAME} RORG $rorg unknown.";
  6307. } else {
  6308. Log3 undef, 2, "EnOcean RORG $rorg received from $senderID unknown.";
  6309. }
  6310. return "";
  6311. }
  6312. if ($rorg eq "40") {
  6313. # chained data message (CDM)
  6314. $data =~ m/^(..)(.*)$/;
  6315. # SEQ evaluation?
  6316. my ($seq, $idx) = (hex($1) & 0xC0, hex($1) & 0x3F);
  6317. $data = $2;
  6318. if ($idx == 0) {
  6319. # first message part
  6320. delete $iohash->{helper}{cdm};
  6321. $data =~ m/^(....)(..)(.*)$/;
  6322. $iohash->{helper}{cdm}{len} = hex($1);
  6323. $iohash->{helper}{cdm}{rorg} = $2;
  6324. $iohash->{helper}{cdm}{data}{$idx} = $3;
  6325. $iohash->{helper}{cdm}{lenCounter} = length($3) / 2;
  6326. my %functionHash = (hash => $iohash, function => "cdm");
  6327. RemoveInternalTimer(\%functionHash);
  6328. InternalTimer(gettimeofday() + 1, "EnOcean_helperClear", \%functionHash, 0);
  6329. #Log3 $IODev, 3, "EnOcean $IODev CDM timer started";
  6330. } else {
  6331. $iohash->{helper}{cdm}{data}{$idx} = $data;
  6332. $iohash->{helper}{cdm}{lenCounter} += length($data) / 2;
  6333. }
  6334. if ($iohash->{helper}{cdm}{lenCounter} >= $iohash->{helper}{cdm}{len}) {
  6335. # data message complete
  6336. # reconstruct RORG, DATA
  6337. my ($idx, $dataPart, @data);
  6338. while (($idx, $dataPart) = each(%{$iohash->{helper}{cdm}{data}})) {
  6339. $data[$idx] = $iohash->{helper}{cdm}{data}{$idx};
  6340. }
  6341. $data = join('', @data);
  6342. $msg[3] = $data;
  6343. $rorg = $iohash->{helper}{cdm}{rorg};
  6344. $msg[2] = $rorg;
  6345. $msg = join(':', @msg);
  6346. $rorgname = $EnO_rorgname{$rorg};
  6347. if (!$rorgname) {
  6348. Log3 undef, 2, "EnOcean RORG $rorg received from $senderID unknown.";
  6349. return "";
  6350. }
  6351. delete $iohash->{helper}{cdm};
  6352. my %functionHash = (hash => $iohash, function => "cdm");
  6353. RemoveInternalTimer(\%functionHash);
  6354. #Log3 $IODev, 3, "EnOcean $IODev CDM concatenated DATA $data";
  6355. } else {
  6356. # wait for next data message part
  6357. return $IODev;
  6358. }
  6359. }
  6360. if($hash) {
  6361. $name = $hash->{NAME};
  6362. if ($rorg eq 'A5' && !(hex(substr($data, 6, 2)) & 8) &&
  6363. hex(substr($data, 0, 2)) >> 2 == 0x3F &&
  6364. (hex(substr($data, 0, 4)) >> 3 & 0x7F) == 0) {
  6365. # find Radio Link Test device
  6366. my $rltHash;
  6367. foreach my $dev (keys %defs) {
  6368. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  6369. next if (!exists($attr{$dev}{subType}));
  6370. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  6371. $rltHash = $defs{$dev};
  6372. last;
  6373. }
  6374. if (defined $rltHash) {
  6375. if ($rltHash != $hash) {
  6376. if (ReadingsVal($rltHash->{NAME}, 'state', '') =~ m/^standby$/) {
  6377. # device is temporarily subType radioLinkTest
  6378. @{$rltHash->{helper}{rlt}{oldDev}} = ($hash, $name, $hash->{DEF});
  6379. CommandModify(undef, "$name 00000000");
  6380. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  6381. $hash = $rltHash;
  6382. $name = $hash->{NAME};
  6383. CommandModify(undef, "$name $senderID");
  6384. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6385. } else {
  6386. # Radio Link Test Devices not ready at the moment
  6387. return '';
  6388. }
  6389. }
  6390. Log3 $name, 4, "EnOcean received RLT Query messsage DATA: $data from DeviceID: $senderID";
  6391. } else {
  6392. Log3 $name, 4, "EnOcean received RLT Query messsage DATA: $data from DeviceID: $senderID";
  6393. }
  6394. } else {
  6395. Log3 $name, 4, "EnOcean $name received PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6396. }
  6397. $manufID = uc(AttrVal($name, "manufID", ""));
  6398. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6399. $filelogName = "FileLog_$name";
  6400. #if ($IODev ne $hash->{IODev}{NAME}) {
  6401. # transceiver wrong
  6402. # Log3 $name, 4, "EnOcean $name locked telegram via $IODev PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6403. # return "";
  6404. #}
  6405. } else {
  6406. # SenderID unknown, created new device
  6407. Log3 undef, 5, "EnOcean received PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6408. my $learningMode = AttrVal($IODev, "learningMode", "demand");
  6409. my $ret = "UNDEFINED EnO_$senderID EnOcean $senderID $msg";
  6410. if ($rorgname =~ m/^GPCD|GPSD|SMLRNANS|SMREC|SMMBOX$/) {
  6411. Log3 undef, 4, "EnOcean Received $rorgname telegram to the unknown device with SenderID $senderID.";
  6412. return '';
  6413. } elsif ($rorg eq 'A5' &&
  6414. hex(substr($data, 0, 2)) >> 2 == 0x3F &&
  6415. (hex(substr($data, 0, 4)) >> 3 & 0x7F) == 0 &&
  6416. !(hex(substr($data, 6, 2)) & 8)) {
  6417. # find Radio Link Test device
  6418. my $rltHash;
  6419. foreach my $dev (keys %defs) {
  6420. next if ($defs{$dev}{TYPE} ne 'EnOcean');
  6421. next if (!exists($attr{$dev}{subType}));
  6422. next if ($attr{$dev}{subType} ne 'radioLinkTest');
  6423. $rltHash = $defs{$dev};
  6424. last;
  6425. }
  6426. if ($rltHash) {
  6427. return '' if (ReadingsVal($rltHash->{NAME}, 'state', '') !~ m/^standby$/);
  6428. $hash = $rltHash;
  6429. $name = $hash->{NAME};
  6430. CommandModify(undef, "$name $senderID");
  6431. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6432. $filelogName = "FileLog_$name";
  6433. Log3 $name, 4, "EnOcean RLT Query messsage DATA: $data from SenderID: $senderID received";
  6434. $manufID = uc(AttrVal($name, "manufID", ""));
  6435. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6436. } else {
  6437. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and RLT Query message, please define it.";
  6438. return $ret;
  6439. }
  6440. } elsif (exists $iohash->{helper}{teachConfirmWaitHash}) {
  6441. # teach-in response with confirm telegram, assign remote device
  6442. $hash = $iohash->{helper}{teachConfirmWaitHash};
  6443. $name = $hash->{NAME};
  6444. # substitute subDef with DEF
  6445. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  6446. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6447. $attr{$name}{subDef} = $hash->{DEF};
  6448. $subDef = $attr{$name}{subDef};
  6449. $hash->{DEF} = $senderID;
  6450. $attr{$name}{comMode} = "confirm";
  6451. $manufID = uc(AttrVal($name, "manufID", ""));
  6452. $filelogName = "FileLog_$name";
  6453. # clear teach-in request
  6454. delete $iohash->{helper}{teachConfirmWaitHash};
  6455. # store changes
  6456. EnOcean_CommandSave(undef, undef);
  6457. push @event, "3:teach:4BS teach-in accepted";
  6458. Log3 $name, 2, "EnOcean $name remote device with SenderID $senderID assigned";
  6459. } elsif ($learningMode eq "demand" && $iohash->{Teach}) {
  6460. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6461. return $ret;
  6462. } elsif ($learningMode eq "nearfield" && $iohash->{Teach} && $RSSI <= 60) {
  6463. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6464. return $ret;
  6465. } elsif ($learningMode eq "always") {
  6466. if ($rorgname =~ m/^UTE|GPTI|GPTR$/) {
  6467. if ($iohash->{Teach}) {
  6468. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6469. return $ret;
  6470. } else {
  6471. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, activate learning mode.";
  6472. return "";
  6473. }
  6474. } elsif ($rorgname =~ m/^SMLRNREQ$/) {
  6475. if ($iohash->{SmartAckLearn}) {
  6476. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6477. return $ret;
  6478. } else {
  6479. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, activate learning mode.";
  6480. return "";
  6481. }
  6482. } else {
  6483. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, please define it.";
  6484. return $ret;
  6485. }
  6486. } else {
  6487. Log3 undef, 4, "EnOcean Unknown device with SenderID $senderID and $rorgname telegram, activate learning mode.";
  6488. return "";
  6489. }
  6490. }
  6491. } elsif ($packetType == 2) {
  6492. # packet type RESPONSE
  6493. #EnOcean:PacketType:ResposeCode:MessageData:OptionalData
  6494. (undef, undef, $funcNumber, $data, $odata) = @msg;
  6495. $data = defined($data) ? $data : '';
  6496. $odata = defined($odata) ? $odata : '';
  6497. my %codes = (
  6498. "00" => "OK",
  6499. "01" => "ERROR",
  6500. "02" => "NOT_SUPPORTED",
  6501. "03" => "WRONG_PARAM",
  6502. "04" => "OPERATION_DENIED",
  6503. "82" => "FLASH_HW_ERROR",
  6504. "90" => "BASEID_OUT_OF_RANGE",
  6505. "91" => "BASEID_MAX_REACHED",
  6506. );
  6507. my $rcTxt = $codes{$funcNumber} if($codes{$funcNumber});
  6508. if($hash) {
  6509. $name = $hash->{NAME};
  6510. $funcNumber = hex($funcNumber);
  6511. Log3 $name, $funcNumber == 0 ? 5 : 2, "EnOcean $name RESPONSE: $rcTxt DATA: $data ODATA: $odata";
  6512. return $name;
  6513. } else {
  6514. Log3 undef, $funcNumber == 0 ? 5 : 2, "EnOcean RESPONSE: $rcTxt DATA: $data ODATA: $odata";
  6515. return "";
  6516. }
  6517. } elsif ($packetType == 4) {
  6518. # packet type EVENT
  6519. #EnOcean:PacketType:EventCode:MessageData
  6520. (undef, undef, $funcNumber, $data) = @msg;
  6521. Log3 undef, 5, "EnOcean EventCode: $funcNumber DATA: $data";
  6522. $funcNumber = hex($funcNumber);
  6523. if ($funcNumber == 2) {
  6524. # smart Ack confirm learn
  6525. my ($priority, $rorg, $func, $type, $postmasterID, $hopCount);
  6526. my $responseTime = 150;
  6527. my $sendData = '';
  6528. my $sendHash = defined($hash) ? $hash : $iohash;
  6529. my $sendName = $sendHash->{NAME};
  6530. $data =~ m/^(..)(....)(..)(..)(..)(..)(........)(........)(..)$/;
  6531. ($priority, $manufID, $rorg, $func, $type, $RSSI, $postmasterID, $senderID, $hopCount) = (hex($1), $2, $3, $4, $5, hex($6), $7, $8, $9);
  6532. #Log3 undef, 2, "EnOcean IOHASH: $iohash PRIORITY: $priority SmartAckLearn: " . (exists($iohash->{SmartAckLearn}) ? 1 : 0) .
  6533. # " SmartAckLearnWait: " . (exists($iohash->{helper}{smartAckLearnWait}) ? $iohash->{helper}{smartAckLearnWait} : '');
  6534. if ($iohash->{SmartAckLearn} ||
  6535. exists($iohash->{helper}{smartAckLearnWait}) && $iohash->{helper}{smartAckLearnWait} eq $sendName) {
  6536. my $subType = "$rorg.$func.$type";
  6537. if (exists $EnO_eepConfig{$subType}) {
  6538. # EEP supported
  6539. if (exists $modules{EnOcean}{defptr}{$senderID}) {
  6540. $hash = $modules{EnOcean}{defptr}{$senderID};
  6541. }
  6542. $rorgname = $EnO_rorgname{$rorg};
  6543. if($hash) {
  6544. delete $iohash->{helper}{smartAckLearnWait};
  6545. $name = $hash->{NAME};
  6546. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6547. if (($priority & 15) == 15) {
  6548. # device exists, learn OUT
  6549. # send response, to delete mailbox
  6550. $rorg = substr(AttrVal($name, "eep", ' '), 0, 2);
  6551. $sendData = sprintf "00%04X20", $responseTime;
  6552. EnOcean_SndRadio(undef, $hash, 2, $rorg, $sendData, $subDef, '00', $hash->{DEF});
  6553. Log3 $name, 2, "EnOcean $name Smart Ack teach-out send";
  6554. Log3 $name, 2, "EnOcean $name device $name deleted";
  6555. CommandDelete(undef, $name);
  6556. EnOcean_CommandSave(undef, undef);
  6557. return '';
  6558. } else {
  6559. # config device
  6560. Log3 $name, 5, "EnOcean $name received PacketType: $packetType EventCode: $funcNumber DATA: $data";
  6561. $attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType};
  6562. $attr{$name}{eep} = "$rorg-$func-$type";
  6563. $manufID = sprintf "%03X", hex($manufID) & 0x7FF;
  6564. $attr{$name}{manufID} = $manufID;
  6565. $manufID = $EnO_manuf{$manufID} if(exists $EnO_manuf{$manufID});
  6566. $attr{$name}{postmasterID} = $postmasterID;
  6567. $hash->{SmartAckRSSI} = $RSSI;
  6568. $attr{$name}{teachMethod} = 'smartAck';
  6569. foreach my $attrCntr (keys %{$EnO_eepConfig{$subType}{attr}}) {
  6570. if ($attrCntr ne "subDef") {
  6571. $attr{$name}{$attrCntr} = $EnO_eepConfig{$subType}{attr}{$attrCntr};
  6572. }
  6573. }
  6574. #if (defined AttrVal($name, 'subDef', undef)) {
  6575. # $subDef = $attr{$name}{subDef};
  6576. #} else {
  6577. #$subDef = $postmasterID;
  6578. #$attr{$name}{subDef} = $postmasterID;
  6579. #}
  6580. $subDef = '0' x 8;
  6581. $attr{$name}{subDef} = '0' x 8;
  6582. # sent response to create mailbox
  6583. $sendData = sprintf "00%04X00", $responseTime;
  6584. EnOcean_SndRadio(undef, $hash, 2, $rorg, $sendData, $subDef, '00', $hash->{DEF});
  6585. readingsSingleUpdate($hash, "teach", "Smart Ack teach-in accepted EEP $rorg-$func-$type Manufacturer: $manufID", 1);
  6586. Log3 $name, 2, "EnOcean $name Smart Ack teach-in accepted EEP $rorg-$func-$type Manufacturer: $manufID";
  6587. EnOcean_CommandSave(undef, undef);
  6588. return $name;
  6589. }
  6590. } else {
  6591. # device unknown
  6592. if (($priority & 5) == 5) {
  6593. # Smart Ack priority ok (place for mailbox, good RSSI, Local)
  6594. Log3 undef, 1, "EnOcean Unknown device with SenderID $senderID and Smart Ack learn In message, please define it.";
  6595. return "UNDEFINED EnO_$senderID EnOcean $senderID $msg";
  6596. } elsif (($priority & 5) == 1) {
  6597. # Smart Ack no place for mailbox
  6598. $sendData = sprintf "00%04X12", $responseTime;
  6599. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6600. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID Discard learn in, postmaster has no place for further mailbox";
  6601. return '';
  6602. } else {
  6603. # Smart Ack priority to low
  6604. $sendData = sprintf "00%04X13", $responseTime;
  6605. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6606. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID Discard learn in, priority to low";
  6607. return '';
  6608. }
  6609. }
  6610. } else {
  6611. # EEP not supported
  6612. # sent response
  6613. $sendData = sprintf "00%04X11", $responseTime;
  6614. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6615. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID with EEP $rorg-$func-$type not supported";
  6616. return '';
  6617. }
  6618. } else {
  6619. # smart ack learn not activated
  6620. $sendData = sprintf "00%04XFF", $responseTime;
  6621. EnOcean_SndRadio(undef, $sendHash, 2, $rorg, $sendData, $postmasterID, '00', $senderID);
  6622. Log3 $sendName, 2, "EnOcean $sendName Smart Ack learn in from SenderID $senderID received, activate learning";
  6623. return '';
  6624. }
  6625. }
  6626. } elsif ($packetType == 6) {
  6627. # packet type SMART ACK
  6628. #EnOcean:PacketType:SmartAckCode:MessageData
  6629. (undef, undef, $funcNumber, $data) = @msg;
  6630. if($hash) {
  6631. $name = $hash->{NAME};
  6632. $subDef = uc(AttrVal($name, "subDef", $hash->{DEF}));
  6633. Log3 $name, 2, "EnOcean $name received PacketType: $packetType Function Number: $funcNumber DATA: $data";
  6634. } else {
  6635. Log3 undef, 2, "EnOcean received PacketType: $packetType Function Number: $funcNumber DATA: $data";
  6636. return "";
  6637. }
  6638. $funcNumber = hex($funcNumber);
  6639. } elsif ($packetType == 7) {
  6640. # packet type REMOTE_MAN_COMMAND
  6641. #EnOcean:PacketType:RORG:MessageData:SourceID:DestinationID:FunctionNumber:ManufacturerID:RSSI:Delay
  6642. (undef, undef, $rorg, $data, $senderID, $destinationID, $funcNumber, $manufID, $RSSI, $delay) = @msg;
  6643. if (exists $modules{EnOcean}{defptr}{$senderID}) {
  6644. $hash = $modules{EnOcean}{defptr}{$senderID};
  6645. $name = $hash->{NAME};
  6646. if (!exists $attr{$name}{remoteID}) {
  6647. $attr{$name}{remoteID} = $senderID;
  6648. Log3 $name, 2, "EnOcean $name remoteID $senderID assigned";
  6649. if (exists($iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash}) &&
  6650. $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash} == $hash) {
  6651. delete $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash};
  6652. }
  6653. }
  6654. } elsif (exists($iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash})) {
  6655. # the remoteID is assigned to the requesting device
  6656. $hash = $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash};
  6657. $name = $hash->{NAME};
  6658. $subDef = '0' x 8;
  6659. $attr{$name}{remoteID} = $senderID;
  6660. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6661. delete $iohash->{helper}{remoteAnswerWait}{hex($funcNumber)}{hash};
  6662. Log3 $name, 2, "EnOcean $name remoteID $senderID assigned";
  6663. #EnOcean_CommandSave(undef, undef);
  6664. } elsif ($destinationID ne 'FFFFFFFF') {
  6665. $hash = $modules{EnOcean}{defptr}{$destinationID};
  6666. }
  6667. #$funcNumber = substr($funcNumber, 1);
  6668. if($hash) {
  6669. $name = $hash->{NAME};
  6670. $manufID = substr($manufID, 1);
  6671. $rorgname = $EnO_rorgname{$rorg};
  6672. $subDef = '0' x 8;
  6673. Log3 $name, 4, "EnOcean $name received PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID
  6674. DestinationID $destinationID Function Number: " . substr($funcNumber, 1) . " ManufacturerID: $manufID";
  6675. $delay = hex($delay);
  6676. $funcNumber = hex($funcNumber);
  6677. $RSSI = hex($RSSI);
  6678. } else {
  6679. if (hex($funcNumber) == 4) {
  6680. #Log3 undef, 1, "EnOcean received remote management query ID from unknown SenderID $senderID, please define device.";
  6681. #return "UNDEFINED EnO_$senderID EnOcean $senderID $msg";
  6682. return '';
  6683. } else {
  6684. return '';
  6685. }
  6686. }
  6687. }
  6688. my $eep = AttrVal($name, "eep", undef);
  6689. my $smartAckLearn = $hash->{IODev}{SmartAckLearn};
  6690. my $teach = $hash->{IODev}{Teach};
  6691. my ($deleteDevice, $oldDevice);
  6692. if (AttrVal($name, "secLevel", "off") =~ m/^encapsulation|encryption$/ &&
  6693. AttrVal($name, "secMode", "") =~ m/^rcv|biDir$/) {
  6694. if ($rorg eq "30" || $rorg eq "31") {
  6695. Log3 $name, 5, "EnOcean $name secure data RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6696. ($err, $rorg, $data) = EnOcean_sec_convertToNonsecure($hash, $rorg, $data);
  6697. if (defined $err) {
  6698. Log3 $name, 2, "EnOcean $name security ERROR: $err";
  6699. return "";
  6700. }
  6701. } elsif ($rorg eq "35") {
  6702. # pass second teach-in telegram
  6703. } else {
  6704. Log3 $name, 2, "EnOcean $name unsecure telegram locked";
  6705. return "";
  6706. }
  6707. if ($rorg eq "32") {
  6708. if (defined $eep) {
  6709. # reconstruct RORG
  6710. $rorg = substr($eep, 0, 2);
  6711. Log3 $name, 5, "EnOcean $name decrypted data RORG: 32 >> $rorg DATA: $data SenderID: $senderID STATUS: $status";
  6712. } else {
  6713. # Teach-In telegram expected
  6714. #####
  6715. # telegram analyse needed >> 1BS, 4BS, UTE
  6716. if (length($data) == 14) {
  6717. $rorg = "D4";
  6718. } else {
  6719. Log3 $name, 2, "EnOcean $name security teach-in failed, UTE message is missing";
  6720. return "";
  6721. }
  6722. }
  6723. }
  6724. }
  6725. if ($rorg eq "A6") {
  6726. # addressing destination telegram (ADT)
  6727. # reconstruct RORG, DATA
  6728. $data =~ m/^(..)(.*)(........)$/;
  6729. ($rorg, $data) = ($1, $2);
  6730. $rorgname = $EnO_rorgname{$rorg};
  6731. if (!$rorgname) {
  6732. Log3 undef, 1, "EnOcean RORG $rorg received from $senderID unknown.";
  6733. return "";
  6734. }
  6735. if ($destinationID ne $3) {
  6736. Log3 $name, 1, "EnOcean $name ADT DestinationID wrong.";
  6737. return "";
  6738. }
  6739. Log3 $name, 1, "EnOcean $name ADT decapsulation RORG: $rorg DATA: $data DestinationID: $3";
  6740. }
  6741. # compute data
  6742. # extract data bytes $db[x] ... $db[0]
  6743. my @db;
  6744. my $dbCntr = 0;
  6745. for (my $strCntr = length($data) / 2 - 1; $strCntr >= 0; $strCntr --) {
  6746. $db[$dbCntr] = hex substr($data, $strCntr * 2, 2);
  6747. $dbCntr ++;
  6748. }
  6749. my $model = AttrVal($name, "model", "");
  6750. my $st = AttrVal($name, "subType", "");
  6751. my $subtypeReading = AttrVal($name, "subTypeReading", undef);
  6752. $st = $subtypeReading if (defined $subtypeReading);
  6753. if ($rorg eq "F6") {
  6754. # RPS Telegram
  6755. my $event = "state";
  6756. my $nu = (hex($status) & 0x10) >> 4;
  6757. # unused flags (AFAIK)
  6758. #push @event, "1:T21:".((hex($status) & 0x20) >> 5);
  6759. #push @event, "1:NU:$nu";
  6760. if ($st eq "FRW" || $st eq "smokeDetector.02") {
  6761. # smoke detector
  6762. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} != $db[0] || ReadingsVal($name, 'alarm', '') eq 'dead_sensor') {
  6763. if ($db[0] == 0x30) {
  6764. push @event, "3:alarm:off";
  6765. push @event, "3:battery:low";
  6766. $msg = ReadingsVal($name, 'state', 'off');
  6767. } elsif ($db[0] == 0x10) {
  6768. push @event, "3:battery:ok";
  6769. push @event, "3:alarm:smoke-alarm";
  6770. $msg = "smoke-alarm";
  6771. } elsif ($db[0] == 0) {
  6772. push @event, "3:alarm:off";
  6773. push @event, "3:battery:ok";
  6774. $msg = "off";
  6775. }
  6776. push @event, "3:$event:$msg";
  6777. $hash->{helper}{lastEvent} = $db[0];
  6778. }
  6779. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  6780. RemoveInternalTimer($hash->{helper}{alarmTimer});
  6781. InternalTimer(gettimeofday() + 1320, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  6782. } elsif ($st eq "windSpeed.00") {
  6783. # wind speed threshold detector
  6784. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} != $db[0] || ReadingsVal($name, 'alarm', '') eq 'dead_sensor') {
  6785. push @event, "3:alarm:off";
  6786. if ($db[0] == 0x30) {
  6787. push @event, "3:battery:low";
  6788. $msg = ReadingsVal($name, 'state', 'off');
  6789. } elsif ($db[0] == 0x10) {
  6790. push @event, "3:windSpeed:on";
  6791. push @event, "3:battery:ok";
  6792. $msg = "on";
  6793. } elsif ($db[0] == 0) {
  6794. push @event, "3:windSpeed:off";
  6795. push @event, "3:battery:ok";
  6796. $msg = "off";
  6797. }
  6798. push @event, "3:$event:$msg";
  6799. $hash->{helper}{lastEvent} = $db[0];
  6800. }
  6801. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  6802. RemoveInternalTimer($hash->{helper}{alarmTimer});
  6803. InternalTimer(gettimeofday() + 1320, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  6804. } elsif ($model eq "FAE14" || $model eq "FHK14" || $model eq "FHK61") {
  6805. # heating/cooling relay FAE14, FHK14, untested
  6806. $event = "controllerMode";
  6807. if ($db[0] == 0x30) {
  6808. # night reduction 2 K
  6809. push @event, "3:energyHoldOff:holdoff";
  6810. $msg = "auto";
  6811. } elsif ($db[0] == 0x10) {
  6812. # off
  6813. push @event, "3:energyHoldOff:normal";
  6814. $msg = "off";
  6815. } elsif ($db[0] == 0x70) {
  6816. # on
  6817. push @event, "3:energyHoldOff:normal";
  6818. $msg = "auto";
  6819. } elsif ($db[0] == 0x50) {
  6820. # night reduction 4 K
  6821. push @event, "3:energyHoldOff:holdoff";
  6822. $msg = "auto";
  6823. }
  6824. push @event, "3:$event:$msg";
  6825. } elsif ($st eq "gateway") {
  6826. # Eltako switching, dimming
  6827. if ($db[0] == 0x70) {
  6828. $msg = "on";
  6829. } elsif ($db[0] == 0x50) {
  6830. $msg = "off";
  6831. } elsif ($db[0] == 0x30) {
  6832. $event = 'alert';
  6833. $msg = "on";
  6834. } elsif ($db[0] == 0x10) {
  6835. $event = 'alert';
  6836. $msg = "off";
  6837. }
  6838. push @event, "3:$event:$msg";
  6839. } elsif ($st eq "manufProfile" && $manufID eq "00D") {
  6840. # Eltako shutter
  6841. if ($db[0] == 0x70) {
  6842. # open
  6843. push @event, "3:endPosition:open_ack";
  6844. $msg = "open_ack";
  6845. } elsif ($db[0] == 0x50) {
  6846. # closed
  6847. push @event, "3:position:100";
  6848. push @event, "3:anglePos:" . AttrVal($name, "angleMax", 90);
  6849. push @event, "3:endPosition:closed";
  6850. $msg = "closed";
  6851. } elsif ($db[0] == 0) {
  6852. # not reached or not available
  6853. push @event, "3:endPosition:not_reached";
  6854. $msg = "not_reached";
  6855. } elsif ($db[0] == 1) {
  6856. # up
  6857. push @event, "3:endPosition:not_reached";
  6858. $msg = "up";
  6859. } elsif ($db[0] == 2) {
  6860. # down
  6861. push @event, "3:endPosition:not_reached";
  6862. $msg = "down";
  6863. }
  6864. push @event, "3:$event:$msg";
  6865. } elsif ($st eq "occupSensor.01" && $model eq "tracker") {
  6866. # tracker
  6867. push @event, "3:button:" . ($db[0] & 0x70 ? "pressed" : "released");
  6868. } elsif ($st eq "switch.7F" && $manufID eq "00D") {
  6869. $msg = $EnO_ptm200btn[($db[0] & 0xE0) >> 5];
  6870. $msg .= "," . $EnO_ptm200btn[($db[0] & 0x0E) >> 1] if ($db[0] & 1);
  6871. $msg .= " released" if (!($db[0] & 0x10));
  6872. push @event, "3:buttons:" . ($db[0] & 0x10 ? "pressed" : "released");
  6873. if ($msg =~ m/A0/) {push @event, "3:channelA:A0";}
  6874. if ($msg =~ m/AI/) {push @event, "3:channelA:AI";}
  6875. if ($msg =~ m/B0/) {push @event, "3:channelB:B0";}
  6876. if ($msg =~ m/BI/) {push @event, "3:channelB:BI";}
  6877. if ($msg =~ m/C0/) {push @event, "3:channelC:C0";}
  6878. if ($msg =~ m/CI/) {push @event, "3:channelC:CI";}
  6879. if ($msg =~ m/D0/) {push @event, "3:channelD:D0";}
  6880. if ($msg =~ m/DI/) {push @event, "3:channelD:DI";}
  6881. push @event, "3:$event:$msg";
  6882. } else {
  6883. if ($nu) {
  6884. if ($st eq "keycard") {
  6885. # Key Card, not tested
  6886. $msg = "keycard_inserted" if ($db[0] == 112);
  6887. } elsif ($st eq "liquidLeakage") {
  6888. # liquid leakage sensor, not tested
  6889. $msg = "wet" if ($db[0] == 0x11);
  6890. } else {
  6891. # Theoretically there can be a released event with some of the A0, BI
  6892. # pins set, but with the plastic cover on this wont happen.
  6893. $msg = $EnO_ptm200btn[($db[0] & 0xE0) >> 5];
  6894. $msg .= "," . $EnO_ptm200btn[($db[0] & 0x0E) >> 1] if ($db[0] & 1);
  6895. $msg .= " released" if (!($db[0] & 0x10));
  6896. push @event, "3:buttons:" . ($db[0] & 0x10 ? "pressed" : "released");
  6897. if ($msg =~ m/A0/) {push @event, "3:channelA:A0";}
  6898. if ($msg =~ m/AI/) {push @event, "3:channelA:AI";}
  6899. if ($msg =~ m/B0/) {push @event, "3:channelB:B0";}
  6900. if ($msg =~ m/BI/) {push @event, "3:channelB:BI";}
  6901. if ($msg =~ m/C0/) {push @event, "3:channelC:C0";}
  6902. if ($msg =~ m/CI/) {push @event, "3:channelC:CI";}
  6903. if ($msg =~ m/D0/) {push @event, "3:channelD:D0";}
  6904. if ($msg =~ m/DI/) {push @event, "3:channelD:DI";}
  6905. }
  6906. } else {
  6907. if ($db[0] & 0xC0) {
  6908. # Only a Mechanical Handle is setting these bits when NU = 0
  6909. $msg = "closed" if ($db[0] == 0xF0);
  6910. $msg = "open" if ($db[0] == 0xE0);
  6911. $msg = "tilted" if ($db[0] == 0xD0);
  6912. $msg = "open_from_tilted" if ($db[0] == 0xC0);
  6913. } elsif ($st eq "keycard") {
  6914. $msg = "keycard_removed";
  6915. } elsif ($st eq "liquidLeakage") {
  6916. $msg = "dry";
  6917. } else {
  6918. $msg = (($db[0] & 0x10) ? "pressed" : "released");
  6919. push @event, "3:buttons:" . ($db[0] & 0x10 ? "pressed" : "released");
  6920. }
  6921. }
  6922. # released events are disturbing when using a remote, since it overwrites
  6923. # the "real" state immediately. In the case of an Eltako FSB14, FSB61 ...
  6924. # the state should remain released. (by Thomas)
  6925. if ($msg =~ m/released$/ &&
  6926. AttrVal($name, "sensorMode", "switch") ne "pushbutton" &&
  6927. $model ne "FT55" && $model ne "FSB14" &&
  6928. $model ne "FSB61" && $model ne "FSB70" &&
  6929. $model ne "FSM12" && $model ne "FSM61" &&
  6930. $model ne "FTS12") {
  6931. $event = "buttons";
  6932. $msg = "released";
  6933. } else {
  6934. push @event, "3:$event:$msg";
  6935. }
  6936. }
  6937. } elsif ($rorg eq "D5") {
  6938. # 1BS telegram
  6939. if ($st eq "radioLinkTest") {
  6940. # Radio Link Test (EEP A5-3F-00)
  6941. @{$hash->{helper}{rlt}{param}} = ('parse', $hash, $data, $subDef, 'master', $RSSI);
  6942. EnOcean_RLT($hash->{helper}{rlt}{param});
  6943. } else {
  6944. # Single Input Contact (EEP D5-00-01)
  6945. # [Eltako FTK, STM-250]
  6946. push @event, "3:state:" . ($db[0] & 1 ? "closed" : "open");
  6947. if (!($db[0] & 8)) {
  6948. # teach-in
  6949. $attr{$name}{eep} = "D5-00-01";
  6950. $attr{$name}{manufID} = "7FF";
  6951. $attr{$name}{subType} = "contact";
  6952. push @event, "3:teach:1BS teach-in accepted EEP D5-00-01 Manufacturer: no ID";
  6953. Log3 $name, 2, "EnOcean $name teach-in EEP D5-00-01 Manufacturer: no ID";
  6954. # store attr subType, manufID ...
  6955. EnOcean_CommandSave(undef, undef);
  6956. }
  6957. }
  6958. } elsif ($rorg eq "A5") {
  6959. # 4BS telegram
  6960. if (($db[0] & 8) == 0) {
  6961. # Teach-In telegram
  6962. if ($teach || AttrVal($hash->{IODev}{NAME}, "learningMode", "demand") eq "always" || $st eq "radioLinkTest") {
  6963. if ($db[0] & 0x80) {
  6964. # 4BS Teach-In telegram with EEP and manufacturer ID
  6965. my $func = sprintf "%02X", ($db[3] >> 2);
  6966. my $type = sprintf "%02X", ((($db[3] & 3) << 5) | ($db[2] >> 3));
  6967. my $mid = sprintf "%03X", ((($db[2] & 7) << 8) | $db[1]);
  6968. # manufID to account for vendor-specific features
  6969. $attr{$name}{manufID} = $mid;
  6970. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  6971. my $st = "A5.$func.$type";
  6972. $attr{$name}{eep} = "A5-$func-$type";
  6973. if ($db[0] & 0x10) {
  6974. # 4BS teach-in bidirectional response received
  6975. Log3 $name, 5, "EnOcean $name 4BS teach-in response message from $senderID received";
  6976. if ($teach && exists($hash->{IODev}{helper}{"4BSRespWait"}{$destinationID})) {
  6977. if ($db[0] & 0x40) {
  6978. # EEP supported
  6979. if ($db[0] & 0x20) {
  6980. # SenderID stored
  6981. Log3 $name, 2, "EnOcean $name 4BS teach-in accepted by $senderID";
  6982. push @event, "3:teach:4BS teach-in accepted EEP $rorg-$func-$type Manufacturer: $mid";
  6983. $attr{$name}{comMode} = "biDir";
  6984. $attr{$name}{destinationID} = "unicast";
  6985. # substitute subDef with DEF
  6986. $attr{$name}{subDef} = $hash->{DEF};
  6987. $hash->{DEF} = $senderID;
  6988. $modules{EnOcean}{defptr}{$senderID} = $hash;
  6989. delete $modules{EnOcean}{defptr}{$destinationID};
  6990. # clear teach-in request
  6991. delete $hash->{IODev}{helper}{"4BSRespWait"}{$destinationID};
  6992. # store attr subType, manufID ...
  6993. EnOcean_CommandSave(undef, undef);
  6994. } else {
  6995. # SenderID not stored / deleted
  6996. Log3 $name, 2, "EnOcean $name 4BS request not accepted by $senderID";
  6997. push @event, "3:teach:4BS request not accepted EEP $rorg-$func-$type Manufacturer: $mid";
  6998. }
  6999. } else {
  7000. # EEP not suppported
  7001. Log3 $name, 2, "EnOcean $name 4BS EEP not supported by $senderID";
  7002. push @event, "3:teach:4BS EEP not supported EEP $rorg-$func-$type Manufacturer: $mid";
  7003. }
  7004. } else {
  7005. Log3 $name, 2, "EnOcean $name 4BS teach-in response message from $senderID ignored";
  7006. }
  7007. } else {
  7008. # 4BS teach-in query
  7009. $attr{$name}{teachMethod} = '4BS';
  7010. if(exists $EnO_eepConfig{$st}{attr}) {
  7011. push @event, "3:teach:4BS teach-in accepted EEP A5-$func-$type Manufacturer: $mid";
  7012. Log3 $name, 2, "EnOcean $name 4BS teach-in accepted EEP A5-$func-$type Manufacturer: $mid";
  7013. foreach my $attrCntr (keys %{$EnO_eepConfig{$st}{attr}}) {
  7014. if ($attrCntr eq "subDef") {
  7015. if (!defined AttrVal($name, $attrCntr, undef)) {
  7016. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_eepConfig{$st}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  7017. }
  7018. } else {
  7019. $attr{$name}{$attrCntr} = $EnO_eepConfig{$st}{attr}{$attrCntr};
  7020. }
  7021. }
  7022. if (exists($hash->{helper}{teachInWait}) && $hash->{helper}{teachInWait} =~ m/^4BS|STE$/) {
  7023. $attr{$filelogName}{logtype} = $EnO_eepConfig{$st}{GPLOT} . 'text'
  7024. if (exists $attr{$filelogName}{logtype});
  7025. EnOcean_CreateSVG(undef, $hash, undef);
  7026. delete $hash->{helper}{teachInWait};
  7027. }
  7028. $st = $EnO_eepConfig{$st}{attr}{subType};
  7029. } else {
  7030. push @event, "3:teach:4BS EEP not supported EEP A5-$func-$type Manufacturer: $mid";
  7031. Log3 $name, 2, "EnOcean $name 4BS EEP not supported EEP A5-$func-$type Manufacturer: $mid";
  7032. $attr{$name}{subType} = "raw";
  7033. $st = "raw";
  7034. }
  7035. if ($teach || $st eq "radioLinkTest") {
  7036. # bidirectional 4BS teach-in
  7037. if ($st eq "hvac.01" || $st eq "MD15") {
  7038. # EEP A5-20-01
  7039. $attr{$name}{comMode} = "biDir";
  7040. $attr{$name}{destinationID} = "unicast";
  7041. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7042. # teach-in response
  7043. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, "800FFFF0", $subDef, "00", $hash->{DEF});
  7044. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7045. readingsSingleUpdate($hash, 'operationMode', 'setpointTemp', 0);
  7046. #####
  7047. #EnOcean_hvac_01Cmd($hash, $packetType, 128); # 128 == 20 degree C
  7048. } elsif ($st eq "hvac.02") {
  7049. # EEP A5-20-02 not supported
  7050. # teach-in response
  7051. $data = sprintf "%06X90", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7052. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7053. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7054. } elsif ($st eq "hvac.03") {
  7055. # EEP A5-20-03 not supported
  7056. # teach-in response
  7057. $data = sprintf "%06X90", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7058. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7059. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7060. } elsif ($st eq "hvac.04") {
  7061. # heating radiator valve actuating drive (EEP A5-20-04)
  7062. $attr{$name}{comMode} = "biDir";
  7063. $attr{$name}{destinationID} = "unicast";
  7064. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7065. # teach-in response
  7066. $data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7067. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, "00", $hash->{DEF});
  7068. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7069. readingsSingleUpdate($hash, 'operationMode', 'setpointTemp', 0);
  7070. } elsif ($st eq "radioLinkTest") {
  7071. # Radio Link Test (EEP A5-3F-00)
  7072. if (ReadingsVal($name, "state", 'standby') eq 'standby') {
  7073. $attr{$name}{comMode} = "biDir";
  7074. $attr{$name}{destinationID} = "unicast";
  7075. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7076. # teach-in response, SenderID not stored
  7077. $data = sprintf "%06XD0", (hex($func) << 7 | hex($type)) << 11 | hex($attr{$name}{manufID});
  7078. #$data = sprintf "%06XD0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7079. #$data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7080. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, "00", $hash->{DEF});
  7081. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7082. @{$hash->{helper}{rlt}{param}} = ('start', $hash, undef, $subDef, 'master', $RSSI);
  7083. EnOcean_RLT($hash->{helper}{rlt}{param});
  7084. }
  7085. #} elsif ($st =~ m/^hvac\.1[0-1]$/) {
  7086. # EEP A5-20-10, A5-20-11
  7087. # teach-in response
  7088. # $data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7089. # EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7090. # Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7091. } elsif (AttrVal($name, "comMode", "") =~ m/^confirm|biDir$/) {
  7092. # confirm telegram requested, teach-in response sent
  7093. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  7094. $data = sprintf "%06XF0", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7095. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, $subDef, "00", $hash->{DEF});
  7096. Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7097. #} else {
  7098. # EEP not supported
  7099. # teach-in response
  7100. # $data = sprintf "%06X90", (hex($func) << 7 | hex($type)) << 11 | 0x7FF;
  7101. # EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $data, "00000000", "00", $hash->{DEF});
  7102. # Log3 $name, 2, "EnOcean $name 4BS teach-in response sent to " . $hash->{DEF};
  7103. }
  7104. }
  7105. }
  7106. # store attr subType, manufID ...
  7107. EnOcean_CommandSave(undef, undef);
  7108. # delete standard readings
  7109. CommandDeleteReading(undef, "$name sensor[0-9]");
  7110. CommandDeleteReading(undef, "$name D[0-9]");
  7111. } else {
  7112. # 4BS Teach-In without EEP and manufacturer ID
  7113. push @event, "3:teach:4BS teach-in accepted: No EEP profile identifier and no Manufacturer ID";
  7114. Log3 $name, 2, "EnOcean $name 4BS teach-in accepted. No EEP profile identifier and no Manufacturer ID";
  7115. $attr{$name}{subType} = "raw";
  7116. $st = "raw";
  7117. }
  7118. } else {
  7119. Log3 $name, 4, "EnOcean $name teach-in with subType $st locked, set transceiver in teach mode.";
  7120. return "";
  7121. }
  7122. } elsif ($st eq "hvac.01" || $st eq "MD15") {
  7123. # Battery Powered Actuator (EEP A5-20-01)
  7124. # [Kieback&Peter MD15-FTL-xx]
  7125. push @event, "3:energyInput:" . (($db[2] & 0x40) ? "enabled" : "disabled");
  7126. my $battery = ($db[2] & 0x10) ? "ok" : "low";
  7127. my $energyStorage;
  7128. if ($db[2] & 0x20) {
  7129. $energyStorage = 'charged';
  7130. $battery = 'ok';
  7131. } else {
  7132. $energyStorage = 'empty';
  7133. }
  7134. push @event, "3:battery:$battery";
  7135. push @event, "3:energyStorage:$energyStorage";
  7136. my $roomTemp = ReadingsVal($name, "roomTemp", 20);
  7137. if ($db[2] & 4) {
  7138. CommandDeleteReading(undef, "$name roomTemp");
  7139. } else {
  7140. $roomTemp = $db[1] * 40 / 255;
  7141. push @event, "3:roomTemp:" . sprintf "%0.1f", $roomTemp;
  7142. }
  7143. my $setpoint = $db[3];
  7144. push @event, "3:setpoint:$setpoint";
  7145. my $maintenanceMode = ReadingsVal($name, "maintenanceMode", ($db[2] & 0x80) ? 'on' : 'off');
  7146. # if ($db[2] & 0x80) {
  7147. # $maintenanceMode = 'on' if (!defined($maintenanceMode));
  7148. # } else {
  7149. # $maintenanceMode = 'off';
  7150. # }
  7151. push @event, "3:cover:" . (($db[2] & 8) ? "open" : "closed");
  7152. push @event, "3:window:" . (($db[2] & 2) ? "open" : "closed");
  7153. push @event, "3:actuatorState:". (($db[2] & 1) ? "obstructed" : "ok");
  7154. push @event, "3:selfCtrl:" . (($db[0] & 4) ? "on" : "off");
  7155. my $functionSelect = 0;
  7156. my $setpointSelect = 0;
  7157. my $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7158. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  7159. my $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7160. my $temperature = ReadingsVal($name, 'temperature', $roomTemp);
  7161. if (!defined(AttrVal($name, "temperatureRefDev", undef))) {
  7162. if ($db[2] & 4) {
  7163. CommandDeleteReading(undef, "$name temperature");
  7164. } else {
  7165. $temperature = $roomTemp;
  7166. readingsSingleUpdate($hash, 'temperature', sprintf("%0.1f", $temperature), 1);
  7167. }
  7168. }
  7169. Log3 $name, 5, "EnOcean $name EnOcean_parse SPT: $setpointTemp SPTS: $setpointTempSet";
  7170. my $operationMode = ReadingsVal($name, "operationMode", 'setpointTemp');
  7171. my $setpointSummerMode = AttrVal($name, "setpointSummerMode", 0);
  7172. my $summerMode = AttrVal($name, "summerMode", "off");
  7173. my $timeDiff = EnOcean_TimeDiff(ReadingsTimestamp($name, 'wakeUpCycle', undef));
  7174. my $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7175. my $wakeUpCycle = 600;
  7176. # calc wakeup cycle
  7177. if ($summerMode eq 'off') {
  7178. $summerMode = 0;
  7179. if ($timeDiff == 0) {
  7180. $wakeUpCycle = 1200;
  7181. } elsif ($timeDiff < 120) {
  7182. $wakeUpCycle = 120;
  7183. } elsif ($timeDiff > 1200) {
  7184. $wakeUpCycle = 1200;
  7185. } else {
  7186. $wakeUpCycle = int($timeDiff);
  7187. }
  7188. } else {
  7189. $summerMode = 8;
  7190. # ignore all commands
  7191. if ($waitingCmds ne "summerMode") {
  7192. $waitingCmds = "no_change";
  7193. CommandDeleteReading(undef, "$name waitingCmds");
  7194. }
  7195. if ($manufID eq '049') {
  7196. $wakeUpCycle = 28800;
  7197. } else {
  7198. $wakeUpCycle = 3600;
  7199. }
  7200. }
  7201. readingsSingleUpdate($hash, 'wakeUpCycle', $wakeUpCycle, 1);
  7202. # set alarm timer
  7203. CommandDeleteReading(undef, "$name alarm");
  7204. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'no_response_from_actuator', 1, 3);
  7205. RemoveInternalTimer($hash->{helper}{alarmTimer});
  7206. InternalTimer(gettimeofday() + $wakeUpCycle * 1.1, "EnOcean_readingsSingleUpdate", $hash->{helper}{alarmTimer}, 0);
  7207. my $actionCmd = AttrVal($name, "rcvRespAction", undef);
  7208. if (defined $actionCmd) {
  7209. my %specials = ("%ACTUATORSTATE" => (($db[2] & 1) ? "obstructed" : "ok"),
  7210. "%BATTERY" => $battery,
  7211. "%COVER" => (($db[2] & 8) ? "open" : "closed"),
  7212. "%ENERGYINPUT" => (($db[2] & 0x40) ? "enabled" : "disabled"),
  7213. "%ENERGYSTORAGE" => $energyStorage,
  7214. "%MAINTENANCEMODE" => $maintenanceMode,
  7215. "%NAME" => $name,
  7216. "%OPERATIONMODE" => $operationMode,
  7217. "%ROOMTEMP" => $roomTemp,
  7218. "%SELFCTRL" => (($db[0] & 4) ? "on" : "off"),
  7219. "%SETPOINT" => $setpoint,
  7220. "%SETPOINTTEMP" => $setpointTemp,
  7221. "%SUMMERMODE" => $summerMode,
  7222. "%TEMPERATURE" => $temperature,
  7223. "%WINDOW" => (($db[2] & 2) ? "open" : "closed"),
  7224. );
  7225. # action exec
  7226. $actionCmd = EvalSpecials($actionCmd, %specials);
  7227. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  7228. Log3 $name, 2, "Encean $name rcvRespAction ERROR: $ret" if($ret);
  7229. $maintenanceMode = ReadingsVal($name, "maintenanceMode", ($db[2] & 0x80) ? 'on' : 'off');
  7230. $operationMode = ReadingsVal($name, "operationMode", 'setpointTemp');
  7231. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7232. $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7233. $temperature = ReadingsVal($name, 'temperature', $roomTemp);
  7234. $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7235. }
  7236. if ($waitingCmds eq "valveOpens") {
  7237. # deactivate PID regulator
  7238. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7239. $setpointSet = 100;
  7240. $db[2] = 0x20;
  7241. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7242. push @event, "3:maintenanceMode:valveOpend:runInit";
  7243. push @event, "3:operationMode:off";
  7244. CommandDeleteReading(undef, "$name setpointSet");
  7245. CommandDeleteReading(undef, "$name setpointTemp");
  7246. CommandDeleteReading(undef, "$name setpointTempSet");
  7247. CommandDeleteReading(undef, "$name waitingCmds");
  7248. $functionSelect = 1;
  7249. $waitingCmds = 0x20;
  7250. } elsif ($waitingCmds eq "valveCloses") {
  7251. if ($maintenanceMode eq "valveOpend:runInit") {
  7252. $setpointSet = 100;
  7253. $db[2] = 0x20;
  7254. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7255. push @event, "3:maintenanceMode:runInit";
  7256. push @event, "3:operationMode:off";
  7257. $functionSelect = 1;
  7258. $waitingCmds = 0x80;
  7259. } else {
  7260. $setpointSet = 0;
  7261. $db[2] = 0x20;
  7262. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7263. push @event, "3:maintenanceMode:valveClosed";
  7264. push @event, "3:operationMode:off";
  7265. CommandDeleteReading(undef, "$name waitingCmds");
  7266. $functionSelect = 1;
  7267. $waitingCmds = 0x10;
  7268. }
  7269. # stop PID regulator
  7270. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7271. CommandDeleteReading(undef, "$name setpointSet");
  7272. CommandDeleteReading(undef, "$name setpointTemp");
  7273. CommandDeleteReading(undef, "$name setpointTempSet");
  7274. } elsif ($waitingCmds eq "runInit") {
  7275. # deactivate PID regulator
  7276. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7277. $setpointSet = 0;
  7278. $db[2] = 0x20;
  7279. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7280. push @event, "3:maintenanceMode:runInit";
  7281. push @event, "3:operationMode:off";
  7282. push @event, "3:waitingCmds:$operationMode";
  7283. #CommandDeleteReading(undef, "$name setpointSet");
  7284. #CommandDeleteReading(undef, "$name setpointTemp");
  7285. #CommandDeleteReading(undef, "$name setpointTempSet");
  7286. #CommandDeleteReading(undef, "$name waitingCmds");
  7287. $functionSelect = 1;
  7288. $waitingCmds = 0x80;
  7289. } elsif ($waitingCmds eq "liftSet") {
  7290. # deactivate PID regulator
  7291. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7292. $setpointSet = 0;
  7293. $db[2] = 0x20;
  7294. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7295. push @event, "3:maintenanceMode:listSet";
  7296. push @event, "3:operationMode:off";
  7297. push @event, "3:waitingCmds:$operationMode";
  7298. #CommandDeleteReading(undef, "$name setpointSet");
  7299. #CommandDeleteReading(undef, "$name setpointTemp");
  7300. #CommandDeleteReading(undef, "$name setpointTempSet");
  7301. #CommandDeleteReading(undef, "$name waitingCmds");
  7302. $functionSelect = 1;
  7303. $waitingCmds = 0x40;
  7304. } elsif ($waitingCmds eq "setpoint") {
  7305. # deactivate PID regulator
  7306. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7307. if ($maintenanceMode eq "valveOpend:runInit") {
  7308. $setpointSet = 100;
  7309. $db[2] = 0x20;
  7310. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7311. push @event, "3:maintenanceMode:runInit";
  7312. push @event, "3:operationMode:off";
  7313. $functionSelect = 1;
  7314. $waitingCmds = 0x80;
  7315. } else {
  7316. $db[2] = (40 - $temperature) * 255 / 40;
  7317. push @event, "3:maintenanceMode:off";
  7318. push @event, "3:operationMode:setpoint";
  7319. CommandDeleteReading(undef, "$name setpointTemp");
  7320. CommandDeleteReading(undef, "$name setpointTempSet");
  7321. CommandDeleteReading(undef, "$name waitingCmds");
  7322. $waitingCmds = 0;
  7323. }
  7324. } elsif ($waitingCmds eq "setpointTemp") {
  7325. if ($maintenanceMode eq "valveOpend:runInit") {
  7326. # deactivate PID regulator
  7327. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7328. $setpointSet = 100;
  7329. $db[2] = 0x20;
  7330. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7331. push @event, "3:maintenanceMode:runInit";
  7332. push @event, "3:operationMode:off";
  7333. $functionSelect = 1;
  7334. $waitingCmds = 0x80;
  7335. } else {
  7336. if (AttrVal($name, "pidCtrl", 'on') eq 'on') {
  7337. # activate PID regulator
  7338. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'actuator', '');
  7339. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7340. } else {
  7341. # deactivate PID regulator
  7342. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7343. # setpoint temperature
  7344. $setpointSet = $setpointTempSet * 255 / 40;
  7345. $setpointSelect = 4;
  7346. }
  7347. $setpointTemp = $setpointTempSet;
  7348. $db[2] = (40 - $temperature) * 255 / 40;
  7349. push @event, "3:setpointTemp:" . sprintf("%0.1f", $setpointTemp);
  7350. push @event, "3:maintenanceMode:off";
  7351. push @event, "3:operationMode:setpointTemp";
  7352. CommandDeleteReading(undef, "$name waitingCmds");
  7353. $waitingCmds = 0;
  7354. }
  7355. } elsif ($waitingCmds eq "summerMode") {
  7356. # deactivate PID regulator
  7357. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7358. $setpointSet = $setpointSummerMode;
  7359. $db[2] = (40 - $temperature) * 255 / 40;
  7360. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7361. push @event, "3:maintenanceMode:off";
  7362. push @event, "3:operationMode:summerMode";
  7363. #CommandDeleteReading(undef, "$name setpointSet");
  7364. CommandDeleteReading(undef, "$name setpointTemp");
  7365. CommandDeleteReading(undef, "$name setpointTempSet");
  7366. CommandDeleteReading(undef, "$name waitingCmds");
  7367. $waitingCmds = 0;
  7368. } elsif ($operationMode eq "setpoint") {
  7369. # deactivate PID regulator
  7370. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7371. if ($maintenanceMode eq "valveOpend:runInit") {
  7372. $setpointSet = 100;
  7373. $db[2] = 0x20;
  7374. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7375. push @event, "3:maintenanceMode:off";
  7376. push @event, "3:operationMode:setpoint";
  7377. $functionSelect = 1;
  7378. $waitingCmds = 0x80;
  7379. } else {
  7380. $db[2] = (40 - $temperature) * 255 / 40;
  7381. push @event, "3:maintenanceMode:off";
  7382. push @event, "3:operationMode:setpoint";
  7383. $waitingCmds = 0;
  7384. }
  7385. } elsif ($operationMode eq "setpointTemp") {
  7386. if ($maintenanceMode eq "valveOpend:runInit") {
  7387. # deactivate PID regulator
  7388. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7389. $setpointSet = 100;
  7390. $db[2] = 0x20;
  7391. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7392. push @event, "3:maintenanceMode:off";
  7393. push @event, "3:operationMode:setpointTemp";
  7394. $functionSelect = 1;
  7395. $waitingCmds = 0x80;
  7396. } else {
  7397. if (AttrVal($name, "pidCtrl", 'on') eq 'on') {
  7398. # activate PID regulator
  7399. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'actuator', '');
  7400. $setpointSet = ReadingsVal($name, "setpointSet", $setpointSet);
  7401. } else {
  7402. # deactivate PID regulator
  7403. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7404. # setpoint temperature
  7405. $setpointSet = $setpointTempSet * 255 / 40;
  7406. $setpointSelect = 4;
  7407. }
  7408. $db[2] = (40 - $temperature) * 255 / 40;
  7409. $setpointTemp = $setpointTempSet;
  7410. push @event, "3:setpointTemp:" . sprintf("%.1f", $setpointTemp);
  7411. push @event, "3:maintenanceMode:off";
  7412. push @event, "3:operationMode:setpointTemp";
  7413. $waitingCmds = 0;
  7414. }
  7415. } elsif ($operationMode eq "summerMode") {
  7416. # deactivate PID regulator
  7417. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7418. $setpointSet = $setpointSummerMode;
  7419. $db[2] = (40 - $temperature) * 255 / 40;
  7420. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7421. push @event, "3:maintenanceMode:off";
  7422. push @event, "3:operationMode:summerMode";
  7423. $waitingCmds = 0;
  7424. } elsif ($maintenanceMode eq "valveOpend:runInit") {
  7425. # deactivate PID regulator
  7426. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7427. $setpointSet = 100;
  7428. $db[2] = 0x20;
  7429. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7430. push @event, "3:maintenanceMode:valveOpend:runInit";
  7431. push @event, "3:operationMode:off";
  7432. #CommandDeleteReading(undef, "$name setpointSet");
  7433. #CommandDeleteReading(undef, "$name setpointTemp");
  7434. #CommandDeleteReading(undef, "$name setpointTempSet");
  7435. #CommandDeleteReading(undef, "$name waitingCmds");
  7436. $functionSelect = 1;
  7437. $waitingCmds = 0x20;
  7438. } elsif ($maintenanceMode eq "valveClosed") {
  7439. # stop PID regulator
  7440. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7441. $setpointSet = 0;
  7442. $db[2] = 0x20;
  7443. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7444. push @event, "3:maintenanceMode:valveClosed";
  7445. push @event, "3:operationMode:off";
  7446. #CommandDeleteReading(undef, "$name setpointSet");
  7447. #CommandDeleteReading(undef, "$name setpointTemp");
  7448. #CommandDeleteReading(undef, "$name setpointTempSet");
  7449. #CommandDeleteReading(undef, "$name waitingCmds");
  7450. $functionSelect = 1;
  7451. $waitingCmds = 0x10;
  7452. } else {
  7453. $db[2] = (40 - $temperature) * 255 / 40;
  7454. $waitingCmds = 0;
  7455. }
  7456. push @event, "3:state:T: " . sprintf("%0.1f", $temperature) . " SPT: " . sprintf("%.1f", $setpointTemp) . " SP: $setpoint";
  7457. # sent message to the actuator
  7458. $data = sprintf "%02X%02X%02X08", $setpointSet, $db[2], $waitingCmds | $summerMode | $setpointSelect | $functionSelect;
  7459. EnOcean_SndRadio(undef, $hash, $packetType, "A5", $data, $subDef, "00", $hash->{DEF});
  7460. } elsif ($st eq "hvac.04") {
  7461. # heating radiator valve actuating drive EEP A5-20-04)
  7462. my %failureCode = (
  7463. 17 => "measurement_error",
  7464. 18 => "battery_empty",
  7465. 20 => "frost_protection",
  7466. 33 => "blocked_valve",
  7467. 36 => "end_point_detection_error",
  7468. 40 => "no_valve",
  7469. 49 => "not_taught_in",
  7470. 53 => "no_response_from_controller",
  7471. 54 => "teach-in_error"
  7472. );
  7473. my $battery = "ok";
  7474. my %displayOrientation = (0 => 0, 90 => 1, 180 => 2, 270 => 3);
  7475. my $feedTemp = ReadingsVal($name, "feedTemp", 20);
  7476. my $roomTemp = ReadingsVal($name, "roomTemp", 20);
  7477. my $setpoint = $db[3];
  7478. push @event, "3:setpoint:$setpoint";
  7479. my $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7480. my $setpointTemp = ReadingsVal($name, "setpointTemp", 20);
  7481. my $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7482. my $temperature = ReadingsVal($name, "temperature", $roomTemp);
  7483. if ($db[0] & 2) {
  7484. if ($setpointTemp == $setpointTempSet) {
  7485. $setpointTemp = sprintf "%0.1f", ($db[2] * 20 / 255 + 10);
  7486. if ($setpointTemp != $setpointTempSet) {
  7487. # setpointTempSet has been changed by actuator
  7488. $setpointTempSet = $setpointTemp;
  7489. readingsSingleUpdate($hash, 'setpointTempSet', $setpointTempSet, 1);
  7490. }
  7491. } else {
  7492. # setpointTempSet has been changed by Fhem
  7493. $setpointTemp = sprintf "%0.1f", ($db[2] * 20 / 255 + 10);
  7494. }
  7495. push @event, "3:setpointTemp:$setpointTemp";
  7496. } else {
  7497. if ($db[0] & 0x80) {
  7498. # temperature measurement inactive
  7499. CommandDeleteReading(undef, "$name feedTemp");
  7500. } else {
  7501. $feedTemp = $db[2] * 60 / 255 + 20;
  7502. push @event, "3:feedTemp:" . sprintf("%0.1f", $feedTemp);
  7503. }
  7504. }
  7505. if ($db[0] & 1) {
  7506. # failure code
  7507. if (exists $failureCode{$db[1]}) {
  7508. push @event, "3:alarm:" . $failureCode{$db[1]};
  7509. $battery = "empty" if ($db[1] == 18);
  7510. } else {
  7511. CommandDeleteReading(undef, "$name alarm");
  7512. }
  7513. } else {
  7514. if ($db[0] & 0x80) {
  7515. # temperature measurement inactive
  7516. CommandDeleteReading(undef, "$name roomTemp");
  7517. } else {
  7518. # room temperature
  7519. $roomTemp = sprintf("%0.1f", ($db[1] * 20 / 255 + 10));
  7520. push @event, "3:roomTemp:$roomTemp";
  7521. CommandDeleteReading(undef, "$name alarm");
  7522. }
  7523. }
  7524. if (!defined(AttrVal($name, "temperatureRefDev", undef))) {
  7525. if ($db[0] & 0x80) {
  7526. # temperature measurement needed, activate temperature measurement
  7527. $attr{$name}{measurementCtrl} = 'enable';
  7528. EnOcean_CommandSave(undef, undef);
  7529. } else {
  7530. $temperature = $roomTemp;
  7531. readingsSingleUpdate($hash, 'temperature', $temperature, 1);
  7532. #push @event, "3:temperature:$temperature";
  7533. }
  7534. }
  7535. push @event, "3:measurementState:" . ($db[0] & 0x80 ? "inactive" : "active");
  7536. push @event, "3:blockKey:" . ($db[0] & 4 ? "yes" : "no");
  7537. push @event, "3:battery:$battery";
  7538. #push @event, "3:state:T: $temperature SPT: $setpointTemp SP: $setpoint";
  7539. if ($db[0] & 0x40) {
  7540. # status request
  7541. # action needed?
  7542. }
  7543. Log3 $name, 5, "EnOcean $name EnOcean_parse SPT: $setpointTemp SPTS: $setpointTempSet";
  7544. my $activatePID = AttrVal($name, 'pidCtrl', 'on') eq 'on' ? 'actuator' : 'stop';
  7545. my $blockKey = ((AttrVal($name, "blockKey", 'no') eq 'yes') ? 1 : 0) << 2;
  7546. my $displayOrientation = $displayOrientation{AttrVal($name, "displayOrientation", 0)} << 4;
  7547. my $maintenanceMode = ReadingsVal($name, "maintenanceMode", "off");
  7548. my $measurementCtrl = (AttrVal($name, 'measurementCtrl', 'enable') eq 'enable') ? 0 : 0x40;
  7549. #my $operationMode = ReadingsVal($name, "operationMode", "off");
  7550. my $operationMode = ReadingsVal($name, "operationMode", ((AttrVal($name, 'pidCtrl', 'on') eq 'on') ? 'setpointTemp' : 'setpoint'));
  7551. my $summerMode = AttrVal($name, "summerMode", "off");
  7552. my $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7553. my $wakeUpCycle = $wakeUpCycle{AttrVal($name, "wakeUpCycle", 300)};
  7554. if ($summerMode eq 'off' && $wakeUpCycle >= 50) {
  7555. # set default Wake-up Cycle (300 s)
  7556. $wakeUpCycle = 9;
  7557. } elsif ($summerMode eq 'on') {
  7558. if ($waitingCmds ne "summerMode") {
  7559. $waitingCmds = "no_change";
  7560. CommandDeleteReading(undef, "$name waitingCmds");
  7561. }
  7562. $setpointSet = 100;
  7563. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7564. $wakeUpCycle = 50 if ($wakeUpCycle < 50);
  7565. }
  7566. my $actionCmd = AttrVal($name, "rcvRespAction", undef);
  7567. if (defined $actionCmd) {
  7568. my %specials = ("%BATTERY" => $battery,
  7569. "%FEEDTEMP" => $feedTemp,
  7570. "%MAINTENANCEMODE" => $maintenanceMode,
  7571. "%NAME" => $name,
  7572. "%OPERATIONMODE" => $operationMode,
  7573. "%ROOMTEMP" => $roomTemp,
  7574. "%SETPOINT" => $setpoint,
  7575. "%SETPOINTTEMP" => $setpointTemp,
  7576. "%SUMMERMODE" => $summerMode,
  7577. "%TEMPERATURE" => $temperature,
  7578. );
  7579. # action exec
  7580. $actionCmd = EvalSpecials($actionCmd, %specials);
  7581. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  7582. Log3 $name, 2, "EnOcean $name rcvRespAction ERROR: $ret" if($ret);
  7583. $maintenanceMode = ReadingsVal($name, "maintenanceMode", 'off');
  7584. $operationMode = ReadingsVal($name, "operationMode", ((AttrVal($name, 'pidCtrl', 'on') eq 'on') ? 'setpointTemp' : 'setpoint'));
  7585. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7586. $setpointTempSet = ReadingsVal($name, "setpointTempSet", $setpointTemp);
  7587. $temperature = ReadingsVal($name, 'temperature', $roomTemp);
  7588. $waitingCmds = ReadingsVal($name, "waitingCmds", "no_change");
  7589. }
  7590. if ($waitingCmds eq "valveOpens") {
  7591. # deactivate PID regulator
  7592. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7593. $setpointSet = 100;
  7594. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7595. push @event, "3:maintenanceMode:valveOpend:runInit";
  7596. push @event, "3:operationMode:off";
  7597. CommandDeleteReading(undef, "$name setpointSet");
  7598. CommandDeleteReading(undef, "$name setpointTemp");
  7599. CommandDeleteReading(undef, "$name setpointTempSet");
  7600. CommandDeleteReading(undef, "$name waitingCmds");
  7601. $waitingCmds = 1;
  7602. } elsif ($waitingCmds eq "valveCloses") {
  7603. if ($maintenanceMode eq "valveOpend:runInit") {
  7604. $setpointSet = 100;
  7605. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7606. push @event, "3:maintenanceMode:runInit";
  7607. push @event, "3:operationMode:off";
  7608. $waitingCmds = 2;
  7609. } else {
  7610. $setpointSet = 0;
  7611. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7612. push @event, "3:maintenanceMode:valveClosed";
  7613. push @event, "3:operationMode:off";
  7614. CommandDeleteReading(undef, "$name waitingCmds");
  7615. $waitingCmds = 3;
  7616. }
  7617. # stop PID regulator
  7618. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7619. CommandDeleteReading(undef, "$name setpointSet");
  7620. CommandDeleteReading(undef, "$name setpointTemp");
  7621. CommandDeleteReading(undef, "$name setpointTempSet");
  7622. } elsif ($waitingCmds eq "runInit") {
  7623. # deactivate PID regulator
  7624. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7625. $setpointSet = 100;
  7626. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7627. push @event, "3:maintenanceMode:runInit";
  7628. push @event, "3:operationMode:off";
  7629. CommandDeleteReading(undef, "$name setpointSet");
  7630. CommandDeleteReading(undef, "$name setpointTemp");
  7631. CommandDeleteReading(undef, "$name setpointTempSet");
  7632. CommandDeleteReading(undef, "$name waitingCmds");
  7633. $waitingCmds = 2;
  7634. } elsif ($waitingCmds eq "setpoint") {
  7635. # deactivate PID regulator
  7636. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7637. if ($maintenanceMode eq "valveOpend:runInit") {
  7638. $setpointSet = 100;
  7639. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7640. push @event, "3:maintenanceMode:runInit";
  7641. push @event, "3:operationMode:off";
  7642. $waitingCmds = 2;
  7643. } else {
  7644. push @event, "3:maintenanceMode:off";
  7645. push @event, "3:operationMode:setpoint";
  7646. #CommandDeleteReading(undef, "$name setpointSet");
  7647. CommandDeleteReading(undef, "$name setpointTemp");
  7648. CommandDeleteReading(undef, "$name setpointTempSet");
  7649. CommandDeleteReading(undef, "$name waitingCmds");
  7650. $waitingCmds = 0;
  7651. }
  7652. } elsif ($waitingCmds eq "setpointTemp") {
  7653. if ($maintenanceMode eq "valveOpend:runInit") {
  7654. # deactivate PID regulator
  7655. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7656. $setpointSet = 100;
  7657. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7658. push @event, "3:maintenanceMode:runInit";
  7659. push @event, "3:operationMode:off";
  7660. $waitingCmds = 2;
  7661. } else {
  7662. # activate PID regulator
  7663. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  7664. $setpointSet = ReadingsVal($name, "setpointSet", $setpoint);
  7665. $setpointTemp = $setpointTempSet;
  7666. push @event, "3:setpointTemp:$setpointTemp";
  7667. push @event, "3:maintenanceMode:off";
  7668. push @event, "3:operationMode:setpointTemp";
  7669. #CommandDeleteReading(undef, "$name setpointSet");
  7670. #CommandDeleteReading(undef, "$name setpointTempSet");
  7671. CommandDeleteReading(undef, "$name waitingCmds");
  7672. $waitingCmds = 0;
  7673. }
  7674. } elsif ($waitingCmds eq "summerMode") {
  7675. # deactivate PID regulator
  7676. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7677. $setpointSet = 100;
  7678. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7679. push @event, "3:maintenanceMode:off";
  7680. push @event, "3:operationMode:summerMode";
  7681. #CommandDeleteReading(undef, "$name setpointSet");
  7682. CommandDeleteReading(undef, "$name setpointTemp");
  7683. CommandDeleteReading(undef, "$name setpointTempSet");
  7684. CommandDeleteReading(undef, "$name waitingCmds");
  7685. $waitingCmds = 0;
  7686. } elsif ($operationMode eq "setpoint") {
  7687. # deactivate PID regulator
  7688. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7689. if ($maintenanceMode eq "valveOpend:runInit") {
  7690. $setpointSet = 100;
  7691. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7692. push @event, "3:maintenanceMode:off";
  7693. push @event, "3:operationMode:setpoint";
  7694. $waitingCmds = 2;
  7695. } else {
  7696. push @event, "3:maintenanceMode:off";
  7697. push @event, "3:operationMode:setpoint";
  7698. #CommandDeleteReading(undef, "$name setpointSet");
  7699. #CommandDeleteReading(undef, "$name setpointTemp");
  7700. #CommandDeleteReading(undef, "$name setpointTempSet");
  7701. #CommandDeleteReading(undef, "$name waitingCmds");
  7702. $waitingCmds = 0;
  7703. }
  7704. } elsif ($operationMode eq "setpointTemp") {
  7705. if ($maintenanceMode eq "valveOpend:runInit") {
  7706. # deactivate PID regulator
  7707. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7708. $setpointSet = 100;
  7709. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7710. push @event, "3:maintenanceMode:off";
  7711. push @event, "3:operationMode:setpointTemp";
  7712. $waitingCmds = 2;
  7713. } else {
  7714. # activate PID regulator
  7715. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, $activatePID, '');
  7716. $setpointSet = ReadingsVal($name, "setpointSet", $setpointSet);
  7717. push @event, "3:setpointTemp:$setpointTemp";
  7718. push @event, "3:maintenanceMode:off";
  7719. push @event, "3:operationMode:setpointTemp";
  7720. #CommandDeleteReading(undef, "$name setpointSet");
  7721. #CommandDeleteReading(undef, "$name setpointTempSet");
  7722. #CommandDeleteReading(undef, "$name waitingCmds");
  7723. $waitingCmds = 0;
  7724. }
  7725. } elsif ($operationMode eq "summerMode") {
  7726. # deactivate PID regulator
  7727. ($err, $logLevel, $response) = EnOcean_setPID(undef, $hash, 'stop', '');
  7728. $setpointSet = 100;
  7729. readingsSingleUpdate($hash, 'setpointSet', $setpointSet, 1);
  7730. push @event, "3:maintenanceMode:off";
  7731. push @event, "3:operationMode:summerMode";
  7732. #CommandDeleteReading(undef, "$name setpointSet");
  7733. #CommandDeleteReading(undef, "$name setpointTemp");
  7734. #CommandDeleteReading(undef, "$name setpointTempSet");
  7735. #CommandDeleteReading(undef, "$name waitingCmds");
  7736. $waitingCmds = 0;
  7737. } else {
  7738. $waitingCmds = 0;
  7739. }
  7740. push @event, "3:state:T: $temperature SPT: $setpointTemp SP: $setpoint";
  7741. # sent message to the actuator
  7742. $data = sprintf "%02X%02X%02X%02X", $setpointSet,
  7743. ($setpointTempSet - 10) / 20 * 255,
  7744. (AttrVal($name, 'pidCtrl', 'on') eq 'on' ? 0 : 0x80) | $measurementCtrl | $wakeUpCycle,
  7745. $displayOrientation | 8 | $blockKey | $waitingCmds;
  7746. EnOcean_SndRadio(undef, $hash, $packetType, "A5", $data, $subDef, "00", $hash->{DEF});
  7747. } elsif ($st eq "hvac.10") {
  7748. # Generic HVAC Interface (EEP A5-20-10)
  7749. my %mode = (
  7750. 0 => "auto",
  7751. 1 => "heat",
  7752. 2 => "morning_warmup",
  7753. 3 => "cool",
  7754. 4 => "night_purge",
  7755. 5 => "precool",
  7756. 6 => "off",
  7757. 7 => "test",
  7758. 8 => "emergency_heat",
  7759. 9 => "fan_only",
  7760. 10 => "free_cool",
  7761. 11 => "ice",
  7762. 12 => "max_heat",
  7763. 13 => "eco",
  7764. 14 => "dehumidification",
  7765. 15 => "calibration",
  7766. 16 => "emergency_cool",
  7767. 17 => "emergency_stream",
  7768. 18 => "max_cool",
  7769. 19 => "hvc_load",
  7770. 20 => "no_load",
  7771. 31 => "auto_heat",
  7772. 32 => "auto_cool",
  7773. );
  7774. if (exists $mode{$db[3]}) {
  7775. push @event, "3:mode:$mode{$db[3]}";
  7776. } else {
  7777. push @event, "3:mode:unknown";
  7778. }
  7779. my %vanePosition = (
  7780. 0 => "auto",
  7781. 1 => "horizontal",
  7782. 2 => "position_2",
  7783. 3 => "position_3",
  7784. 4 => "position_4",
  7785. 5 => "vertical",
  7786. 6 => "swing",
  7787. 11 => "vertical_swing",
  7788. 12 => "horizontal_swing",
  7789. 13 => "hor_vert_swing",
  7790. 14 => "stop_swing",
  7791. );
  7792. my $vanePosition = $db[2] >> 4;
  7793. if (exists $vanePosition{$vanePosition}) {
  7794. push @event, "3:vanePosition:$vanePosition{$vanePosition}";
  7795. } else {
  7796. push @event, "3:vanePosition:unknown";
  7797. }
  7798. my $fanSpeed = $db[2] & 0x0F;
  7799. if ($fanSpeed == 0) {
  7800. push @event, "3:fanSpeed:auto";
  7801. } elsif ($fanSpeed > 0 && $fanSpeed < 15) {
  7802. push @event, "3:fanSpeed:" . $fanSpeed;
  7803. } else {
  7804. push @event, "3:fanSpeed:unknown";
  7805. }
  7806. if ($db[1] == 255) {
  7807. push @event, "3:ctrl:auto";
  7808. } elsif ($db[1] >= 0 && $db[1] <= 100) {
  7809. push @event, "3:ctrl:" . $db[1];
  7810. } else {
  7811. push @event, "3:ctrl:unknown";
  7812. }
  7813. my $occupancy = ($db[0] & 6) >> 1;
  7814. if ($occupancy == 0) {
  7815. push @event, "3:occupancy:occupied";
  7816. } elsif ($occupancy == 1) {
  7817. push @event, "3:occupancy:standby";
  7818. } elsif ($occupancy == 2) {
  7819. push @event, "3:occupancy:unoccupied";
  7820. } else {
  7821. push @event, "3:occupancy:off";
  7822. }
  7823. push @event, "3:powerSwitch:" . ($db[0] & 1 ? "on" : "off");
  7824. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  7825. } elsif ($st eq "hvac.11") {
  7826. # Generic HVAC Interface - Error Control (EEP A5-20-11)
  7827. push @event, "3:errorCode:" . hex(substr($data, 0, 4));
  7828. push @event, "3:otherDisable:" . ($db[1] & 8 ? "disabled" : "enabled");
  7829. push @event, "3:windowDisable:" . ($db[1] & 4 ? "disabled" : "enabled");
  7830. push @event, "3:keyCardDisable:" . ($db[1] & 2 ? "disabled" : "enabled");
  7831. push @event, "3:externalDisable:" . ($db[1] & 1 ? "disabled" : "enabled");
  7832. push @event, "3:remoteCtrl:" . ($db[0] & 4 ? "disabled" : "enabled");
  7833. push @event, "3:window:" . ($db[0] & 2 ? "closed" : "opened");
  7834. push @event, "3:alarm:" . ($db[0] & 1 ? "error" : "ok");
  7835. push @event, "3:state:" . ($db[0] & 1 ? "error" : "ok");
  7836. } elsif ($st =~ m/^tempSensor/) {
  7837. # Temperature Sensor with with different ranges (EEP A5-02-01 ... A5-02-1B)
  7838. # $db[1] is the temperature where 0x00 = max °C ... 0xFF = min °C
  7839. my $temp;
  7840. $temp = sprintf "%0.1f", 0 - $db[1] / 6.375 if ($st eq "tempSensor.01");
  7841. $temp = sprintf "%0.1f", 10 - $db[1] / 6.375 if ($st eq "tempSensor.02");
  7842. $temp = sprintf "%0.1f", 20 - $db[1] / 6.375 if ($st eq "tempSensor.03");
  7843. $temp = sprintf "%0.1f", 30 - $db[1] / 6.375 if ($st eq "tempSensor.04");
  7844. $temp = sprintf "%0.1f", 40 - $db[1] / 6.375 if ($st eq "tempSensor.05");
  7845. $temp = sprintf "%0.1f", 50 - $db[1] / 6.375 if ($st eq "tempSensor.06");
  7846. $temp = sprintf "%0.1f", 60 - $db[1] / 6.375 if ($st eq "tempSensor.07");
  7847. $temp = sprintf "%0.1f", 70 - $db[1] / 6.375 if ($st eq "tempSensor.08");
  7848. $temp = sprintf "%0.1f", 80 - $db[1] / 6.375 if ($st eq "tempSensor.09");
  7849. $temp = sprintf "%0.1f", 90 - $db[1] / 6.375 if ($st eq "tempSensor.0A");
  7850. $temp = sprintf "%0.1f", 100 - $db[1] / 6.375 if ($st eq "tempSensor.0B");
  7851. $temp = sprintf "%0.1f", 20 - $db[1] / 3.1875 if ($st eq "tempSensor.10");
  7852. $temp = sprintf "%0.1f", 30 - $db[1] / 3.1875 if ($st eq "tempSensor.11");
  7853. $temp = sprintf "%0.1f", 40 - $db[1] / 3.1875 if ($st eq "tempSensor.12");
  7854. $temp = sprintf "%0.1f", 50 - $db[1] / 3.1875 if ($st eq "tempSensor.13");
  7855. $temp = sprintf "%0.1f", 60 - $db[1] / 3.1875 if ($st eq "tempSensor.14");
  7856. $temp = sprintf "%0.1f", 70 - $db[1] / 3.1875 if ($st eq "tempSensor.15");
  7857. $temp = sprintf "%0.1f", 80 - $db[1] / 3.1875 if ($st eq "tempSensor.16");
  7858. $temp = sprintf "%0.1f", 90 - $db[1] / 3.1875 if ($st eq "tempSensor.17");
  7859. $temp = sprintf "%0.1f", 100 - $db[1] / 3.1875 if ($st eq "tempSensor.18");
  7860. $temp = sprintf "%0.1f", 110 - $db[1] / 3.1875 if ($st eq "tempSensor.19");
  7861. $temp = sprintf "%0.1f", 120 - $db[1] / 3.1875 if ($st eq "tempSensor.1A");
  7862. $temp = sprintf "%0.1f", 130 - $db[1] / 3.1875 if ($st eq "tempSensor.1B");
  7863. $temp = sprintf "%0.2f", 41.2 - (($db[2] << 8) | $db[1]) / 20 if ($st eq "tempSensor.20");
  7864. $temp = sprintf "%0.1f", 62.3 - (($db[2] << 8) | $db[1]) / 10 if ($st eq "tempSensor.30");
  7865. push @event, "3:temperature:$temp";
  7866. push @event, "3:state:$temp";
  7867. } elsif ($st eq "COSensor.01") {
  7868. # Gas Sensor, CO Sensor (EEP A5-09-01)
  7869. # [untested]
  7870. # $db[3] is the CO concentration where 0x00 = 0 ppm ... 0xFF = 255 ppm
  7871. # $db[1] is the temperature where 0x00 = 0 °C ... 0xFF = 255 °C
  7872. # $db[0] bit D1 temperature sensor available 0 = no, 1 = yes
  7873. my $coChannel1 = $db[3];
  7874. push @event, "3:CO:$coChannel1";
  7875. if ($db[0] & 2) {
  7876. my $temp = $db[1];
  7877. push @event, "3:temperature:$temp";
  7878. }
  7879. push @event, "3:state:$coChannel1";
  7880. } elsif ($st eq "COSensor.02") {
  7881. # Gas Sensor, CO Sensor (EEP A5-09-02)
  7882. # [untested]
  7883. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  7884. # $db[2] is the CO concentration where 0x00 = 0 ppm ... 0xFF = 1020 ppm
  7885. # $db[1] is the temperature where 0x00 = 0 °C ... 0xFF = 51 °C
  7886. # $db[0]_bit_1 temperature sensor available 0 = no, 1 = yes
  7887. my $coChannel1 = $db[2] << 2;
  7888. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  7889. push @event, "3:CO:$coChannel1";
  7890. if ($db[0] & 2) {
  7891. my $temp = sprintf "%0.1f", $db[1] * 0.2;
  7892. push @event, "3:temperature:$temp";
  7893. }
  7894. push @event, "3:voltage:$voltage";
  7895. push @event, "3:state:$coChannel1";
  7896. } elsif ($st eq "tempHumiCO2Sensor.01") {
  7897. # Gas Sensor, CO2 Sensor (EEP A5-09-04)
  7898. # [Thermokon SR04 CO2 *, Eltako FCOTF63, untested]
  7899. # $db[3] is the humidity where 0x00 = 0 %rH ... 0xC8 = 100 %rH
  7900. # $db[2] is the CO2 concentration where 0x00 = 0 ppm ... 0xFF = 2500 ppm
  7901. # $db[1] is the temperature where 0x00 = 0°C ... 0xFF = +51 °C
  7902. # $db[0] bit D2 humidity sensor available 0 = no, 1 = yes
  7903. # $db[0] bit D1 temperature sensor available 0 = no, 1 = yes
  7904. my $humi = "-";
  7905. my $temp = "-";
  7906. my $airQuality;
  7907. if ($db[0] & 4) {
  7908. $humi = $db[3] >> 1;
  7909. push @event, "3:humidity:$humi";
  7910. }
  7911. my $co2 = sprintf "%d", $db[2] * 10;
  7912. push @event, "3:CO2:$co2";
  7913. if ($db[0] & 2) {
  7914. $temp = sprintf "%0.1f", $db[1] * 51 / 255 ;
  7915. push @event, "3:temperature:$temp";
  7916. }
  7917. if ($co2 <= 400) {
  7918. $airQuality = "high";
  7919. } elsif ($co2 <= 600) {
  7920. $airQuality = "mean";
  7921. } elsif ($co2 <= 1000) {
  7922. $airQuality = "moderate";
  7923. } else {
  7924. $airQuality = "low";
  7925. }
  7926. push @event, "3:airQuality:$airQuality";
  7927. push @event, "3:state:T: $temp H: $humi CO2: $co2 AQ: $airQuality";
  7928. } elsif ($st eq "radonSensor.01") {
  7929. # Gas Sensor, Radon Sensor (EEP A5-09-06)
  7930. # [untested]
  7931. # $db[3]_bit_7 ... $db[2]_bit_6 is the radon activity where 0 = 0 Bq/m3 ... 1023 = 1023 Bq/m3
  7932. my $rn = $db[3] << 2 | $db[2] >> 6;
  7933. push @event, "3:Rn:$rn";
  7934. push @event, "3:state:$rn";
  7935. } elsif ($st eq "vocSensor.01") {
  7936. # Gas Sensor, VOC Sensor (EEP A5-09-05, A5-09-0C)
  7937. # [untested]
  7938. # $db[3]_bit_7 ... $db[2]_bit_0 is the VOC concentration where 0 = 0 ppb ... 65535 = 65535 ppb
  7939. # $db[1] is the VOC identification
  7940. # $db[0]_bit_1 ... $db[0]_bit_0 is the scale multiplier
  7941. my $vocSCM = $db[0] & 3;
  7942. if ($vocSCM == 3) {
  7943. $vocSCM = 10;
  7944. } elsif ($vocSCM == 2) {
  7945. $vocSCM = 1;
  7946. } elsif ($vocSCM == 1) {
  7947. $vocSCM = 0.1;
  7948. } else {
  7949. $vocSCM = 0.01;
  7950. }
  7951. my $vocConc = sprintf "%f", ($db[3] << 8 | $db[2]) * $vocSCM;
  7952. my %vocID = (
  7953. 0 => "VOCT",
  7954. 1 => "Formaldehyde",
  7955. 2 => "Benzene",
  7956. 3 => "Styrene",
  7957. 4 => "Toluene",
  7958. 5 => "Tetrachloroethylene",
  7959. 6 => "Xylene",
  7960. 7 => "n-Hexane",
  7961. 8 => "n-Octane",
  7962. 9 => "Cyclopentane",
  7963. 10 => "Methanol",
  7964. 11 => "Ethanol",
  7965. 12 => "1-Pentanol",
  7966. 13 => "Acetone",
  7967. 14 => "Ethylene Oxide",
  7968. 15 => "Acetaldehyde ue",
  7969. 16 => "Acetic Acid",
  7970. 17 => "Propionice Acid",
  7971. 18 => "Valeric Acid",
  7972. 19 => "Butyric Acid",
  7973. 20 => "Ammoniac",
  7974. 22 => "Hydrogen Sulfide",
  7975. 23 => "Dimethylsulfide",
  7976. 24 => "2-Butanol",
  7977. 25 => "2-Methylpropanol",
  7978. 26 => "Diethyl Ether",
  7979. 27 => "Naphthalene",
  7980. 28 => "4-Phenylcyclohexene",
  7981. 29 => "Limonene",
  7982. 30 => "Tricloroethylene",
  7983. 31 => "Isovaleric Acid",
  7984. 32 => "Indole",
  7985. 33 => "Cadaverine",
  7986. 34 => "Putrescine",
  7987. 35 => "Caproic Acid",
  7988. 255 => "Ozone",
  7989. );
  7990. if (exists $vocID{$db[1]}) {
  7991. push @event, "3:vocName:$vocID{$db[1]}";
  7992. } else {
  7993. push @event, "3:vocName:unknown";
  7994. }
  7995. push @event, "3:concentration:$vocConc";
  7996. push @event, "3:concentrationUnit:" . $db[0] & 4 ? 'ug/m3' : 'ppb';
  7997. push @event, "3:state:$vocConc";
  7998. } elsif ($st eq "particlesSensor.01") {
  7999. # Gas Sensor, Particles Sensor (EEP A5-09-07)
  8000. # [untested]
  8001. # $db[3]_bit_7 ... $db[2]_bit_7 is the particle concentration < 10 µm
  8002. # where 0 = 0 µg/m3 ... 511 = 511 µg/m3
  8003. # $db[2]_bit_6 ... $db[1]_bit_6 is the particle concentration < 2.5 µm
  8004. # where 0 = 0 µg/m3 ... 511 = 511 µg/m3
  8005. # $db[1]_bit_5 ... $db[0]_bit_5 is the particle concentration < 1 µm
  8006. # where 0 = 0 µg/m3 ... 511 = 511 µg/m3
  8007. # $db[0]_bit_2 = 1 = Sensor PM10 active
  8008. # $db[0]_bit_1 = 1 = Sensor PM2_5 active
  8009. # $db[0]_bit_0 = 1 = Sensor PM1 active
  8010. my $pm_10 = "inactive";
  8011. my $pm_2_5 = "inactive";
  8012. my $pm_1 = "inactive";
  8013. if ($db[0] & 4) {$pm_10 = $db[3] << 1 | $db[2] >> 7;}
  8014. if ($db[0] & 2) {$pm_2_5 = ($db[2] & 0x7F) << 1 | $db[1] >> 7;}
  8015. if ($db[0] & 1) {$pm_1 = ($db[1] & 0x3F) << 3 | $db[0] >> 5;}
  8016. push @event, "3:particles_10:$pm_10";
  8017. push @event, "3:particles_2_5:$pm_2_5";
  8018. push @event, "3:particles_1:$pm_1";
  8019. push @event, "3:state:PM10: $pm_10 PM2_5: $pm_2_5 PM1: $pm_1";
  8020. } elsif ($st eq "CO2Sensor.01") {
  8021. # CO2 Sensor (EEP A5-09-08, A5-09-09)
  8022. # [untested]
  8023. # $db[1] is the CO2 concentration where 0x00 = 0 ppm ... 0xFF = 2000 ppm
  8024. # $db[0]_bit_2 is power failure detection
  8025. my $co2 = $db[1] / 255 * 2000;
  8026. push @event, "3:powerFailureDetection:" . ($db[0] & 4 ? "detected" : "not_detected");
  8027. push @event, "3:CO2:$co2";
  8028. push @event, "3:state:$co2";
  8029. } elsif ($st eq "HSensor.01") {
  8030. # H Sensor (EEP A5-09-0A)
  8031. # [untested]
  8032. # $db[3]_$db[2] is the H concentration where 0x00 = 0 ppm ... 0xFFFF = 2000 ppm
  8033. my $hydro = ($db[3] << 8 | $db[2]) / 65535 * 2000;
  8034. push @event, "3:voltage:" . sprintf("%0.1f", (($db[0] & 0xF0) >> 4) / 15 * 3 + 2) if ($db[0] & 1);
  8035. push @event, "3:temperature:" . sprintf("%0.1f", $db[1] / 255 * 80 - 20) if ($db[0] & 2);
  8036. push @event, "3:H:" . sprintf "%0.2f", $hydro;
  8037. push @event, "3:state:" . sprintf "%0.2f", $hydro;
  8038. } elsif ($st eq "radiationSensor.01") {
  8039. # Radiation Sensor (EEP A5-09-0B)
  8040. # [untested]
  8041. # $db[2]_$db[1] is the radioactivity where 0x00 = 0 ... 0xFFFF = 65535
  8042. my %scaleMulti = (
  8043. 0 => 0.001,
  8044. 1 => 0.01,
  8045. 2 => 0.1,
  8046. 3 => 1,
  8047. 4 => 10,
  8048. 5 => 100,
  8049. 6 => 1000,
  8050. 7 => 10000,
  8051. 8 => 100000
  8052. );
  8053. my $scaleMulti = ($db[0] & 0xF0) >> 4;
  8054. my $scaleDecimals;
  8055. if ($scaleMulti <= 2) {
  8056. $scaleDecimals = "%0." . (3 - $scaleMulti) . "f";
  8057. } else {
  8058. $scaleDecimals = "%d"
  8059. }
  8060. $scaleMulti = $scaleMulti{$scaleMulti} if (exists $scaleMulti{$scaleMulti});
  8061. my %unit = (
  8062. 0 => "uSv/h",
  8063. 1 => "cpm",
  8064. 2 => "Bq/L",
  8065. 3 => "Bq/kg"
  8066. );
  8067. my $unit = ($db[0] & 6) >> 1;
  8068. $unit = $unit{$unit};
  8069. my $radioactivity = $db[2] << 8 | $db[1];
  8070. push @event, "3:radioactivity:" . sprintf "$scaleDecimals", $radioactivity * $scaleMulti;
  8071. push @event, "3:radioactivityUnit:$unit";
  8072. push @event, "3:voltage:" . sprintf("%0.1f", (($db[3] & 0xF0) >> 4) / 15 * 3 + 2) if ($db[0] & 1);
  8073. push @event, "3:state:" . sprintf "$scaleDecimals", $radioactivity * $scaleMulti;
  8074. } elsif ($st eq "roomSensorControl.05") {
  8075. # Room Sensor and Control Unit (EEP A5-10-01 ... A5-10-0D)
  8076. # [Eltako FTR55D, FTR55H, Thermokon SR04 *, Thanos SR *, untested]
  8077. # $db[3] is the fan speed or night reduction for Eltako
  8078. # $db[2] is the setpoint where 0x00 = min ... 0xFF = max or
  8079. # reference temperature for Eltako where 0x00 = 0°C ... 0xFF = 40°C
  8080. # $db[1] is the temperature where 0x00 = +40°C ... 0xFF = 0°C
  8081. # $db[0]_bit_0 is the occupy button, pushbutton or slide switch
  8082. my $temp = sprintf "%0.1f", 40 - $db[1] / 6.375;
  8083. if ($manufID eq "00D") {
  8084. my $nightReduction = 0;
  8085. $nightReduction = 1 if ($db[3] == 0x06);
  8086. $nightReduction = 2 if ($db[3] == 0x0C);
  8087. $nightReduction = 3 if ($db[3] == 0x13);
  8088. $nightReduction = 4 if ($db[3] == 0x19);
  8089. $nightReduction = 5 if ($db[3] == 0x1F);
  8090. my $setpointTemp = sprintf "%0.1f", $db[2] / 6.375;
  8091. push @event, "3:state:T: $temp SPT: $setpointTemp NR: $nightReduction";
  8092. push @event, "3:nightReduction:$nightReduction";
  8093. push @event, "3:setpointTemp:$setpointTemp";
  8094. } else {
  8095. my $fspeed = 3;
  8096. $fspeed = 2 if ($db[3] >= 145);
  8097. $fspeed = 1 if ($db[3] >= 165);
  8098. $fspeed = 0 if ($db[3] >= 190);
  8099. $fspeed = "auto" if ($db[3] >= 210);
  8100. my $switch = $db[0] & 1 ? "on" : "off";
  8101. push @event, "3:state:T: $temp SP: $db[2] F: $fspeed SW: $switch";
  8102. push @event, "3:fanStage:$fspeed";
  8103. push @event, "3:switch:$switch";
  8104. push @event, "3:setpoint:$db[2]";
  8105. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[2], 0, 255);
  8106. if (defined $setpointScaled) {
  8107. push @event, "3:setpointScaled:" . $setpointScaled;
  8108. }
  8109. }
  8110. push @event, "3:temperature:$temp";
  8111. } elsif ($st eq "roomSensorControl.01") {
  8112. # Room Sensor and Control Unit (EEP A5-04-01, A5-10-10 ... A5-10-14)
  8113. # [Thermokon SR04 * rH, Thanus SR *, untested]
  8114. # $db[3] is the setpoint where 0x00 = min ... 0xFF = max
  8115. # $db[2] is the humidity where 0x00 = 0%rH ... 0xFA = 100%rH
  8116. # $db[1] is the temperature where 0x00 = 0°C ... 0xFA = +40°C
  8117. # $db[0] bit D0 is the occupy button, pushbutton or slide switch
  8118. my $temp = sprintf "%0.1f", $db[1] * 40 / 250;
  8119. my $humi = sprintf "%d", $db[2] / 2.5;
  8120. my $switch = $db[0] & 1;
  8121. push @event, "3:humidity:$humi";
  8122. push @event, "3:temperature:$temp";
  8123. if ($manufID eq "039") {
  8124. my $brightness = sprintf "%d", $db[3] * 117;
  8125. push @event, "3:brightness:$brightness";
  8126. push @event, "3:state:T: $temp H: $humi B: $brightness";
  8127. } else {
  8128. push @event, "3:setpoint:$db[3]";
  8129. push @event, "3:state:T: $temp H: $humi SP: $db[3] SW: $switch";
  8130. push @event, "3:switch:$switch";
  8131. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[3], 0, 255);
  8132. if (defined $setpointScaled) {
  8133. push @event, "3:setpointScaled:" . $setpointScaled;
  8134. }
  8135. }
  8136. } elsif ($st eq "roomSensorControl.02") {
  8137. # Room Sensor and Control Unit (A5-10-15 ... A5-10-17)
  8138. # [untested]
  8139. # $db[2] bit D7 ... D2 is the setpoint where 0 = min ... 63 = max
  8140. # $db[2] bit D1 ... $db[1] bit D0 is the temperature where 0 = -10°C ... 1023 = +41.2°C
  8141. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8142. my $temp = sprintf "%0.2f", -10 + ((($db[2] & 3) << 8) | $db[1]) / 19.98;
  8143. my $setpoint = ($db[2] & 0xFC) >> 2;
  8144. my $presence = $db[0] & 1 ? "absent" : "present";
  8145. push @event, "3:state:T: $temp SP: $setpoint P: $presence";
  8146. push @event, "3:presence:$presence";
  8147. push @event, "3:setpoint:$setpoint";
  8148. push @event, "3:temperature:$temp";
  8149. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[2], 0, 255);
  8150. if (defined $setpointScaled) {
  8151. push @event, "3:setpointScaled:" . $setpointScaled;
  8152. }
  8153. } elsif ($st eq "roomSensorControl.18") {
  8154. # Room Sensor and Control Unit (A5-10-18)
  8155. # [untested]
  8156. # $db[3] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8157. # $db[2] is the setpoint where 250 = 0 °C ... 0 = 40 °C
  8158. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8159. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8160. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8161. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8162. my $lux = $db[3] << 2;
  8163. if ($db[3] == 251) {$lux = "over range";}
  8164. my $setpoint = sprintf "%0.1f", 40 - $db[2] * 40 / 250;
  8165. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8166. my $fanSpeed;
  8167. if ((($db[0] & 0x70) >> 4) == 0) {
  8168. $fanSpeed = "auto";
  8169. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8170. $fanSpeed = "off";
  8171. } else {
  8172. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8173. }
  8174. my $presence;
  8175. if ($db[0] & 2) {
  8176. $presence = "disabled";
  8177. } else {
  8178. $presence = $db[0] & 1 ? "absent" : "present";
  8179. }
  8180. push @event, "3:brightness:$lux";
  8181. push @event, "3:fan:$fanSpeed";
  8182. push @event, "3:presence:$presence";
  8183. push @event, "3:setpoint:$setpoint";
  8184. push @event, "3:temperature:$temp";
  8185. push @event, "3:state:T: $temp B: $lux F: $fanSpeed SP: $setpoint P: $presence";
  8186. } elsif ($st eq "roomSensorControl.19") {
  8187. # Room Sensor and Control Unit (A5-10-19)
  8188. # [untested]
  8189. # $db[3] is the humidity where min 0x00 = 0 %rH, max 0xFA = 10 %rH
  8190. # $db[2] is the setpoint where 250 = 0 °C ... 0 = 40 °C
  8191. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8192. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8193. # $db[0]_bit_1 is Occupany Button where 0 = pressed, 1 = released
  8194. # $db[0]_bit_0 is Occupany enable where 0 = enabled, 1 = disabled
  8195. my $humi = $db[3] / 2.5;
  8196. my $setpoint = sprintf "%0.1f", 40 - $db[2] * 40 / 250;
  8197. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8198. my $fanSpeed;
  8199. if ((($db[0] & 0x70) >> 4) == 0) {
  8200. $fanSpeed = "auto";
  8201. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8202. $fanSpeed = "off";
  8203. } else {
  8204. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8205. }
  8206. my $presence;
  8207. if ($db[0] & 1) {
  8208. $presence = "disabled";
  8209. } else {
  8210. $presence = $db[0] & 2 ? "absent" : "present";
  8211. }
  8212. push @event, "3:fan:$fanSpeed";
  8213. push @event, "3:humidity:$humi";
  8214. push @event, "3:presence:$presence";
  8215. push @event, "3:setpoint:$setpoint";
  8216. push @event, "3:temperature:$temp";
  8217. push @event, "3:state:T: $temp H: $humi F: $fanSpeed SP: $setpoint P: $presence";
  8218. } elsif ($st eq "roomSensorControl.1A") {
  8219. # Room Sensor and Control Unit (A5-10-1A)
  8220. # [untested]
  8221. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8222. # $db[3] > 0xFA is error code
  8223. # $db[2] is the setpoint where 250 = 0 °C ... 0 = 40 °C
  8224. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8225. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8226. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8227. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8228. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8229. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8230. my $setpoint = sprintf "%0.1f", 40 - $db[2] * 40 / 250;
  8231. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8232. my $fanSpeed;
  8233. if ((($db[0] & 0x70) >> 4) == 0) {
  8234. $fanSpeed = "auto";
  8235. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8236. $fanSpeed = "off";
  8237. } else {
  8238. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8239. }
  8240. my $presence;
  8241. if ($db[0] & 2) {
  8242. $presence = "disabled";
  8243. } else {
  8244. $presence = $db[0] & 1 ? "absent" : "present";
  8245. }
  8246. push @event, "3:fan:$fanSpeed";
  8247. push @event, "3:presence:$presence";
  8248. push @event, "3:setpoint:$setpoint";
  8249. push @event, "3:temperature:$temp";
  8250. push @event, "3:voltage:$voltage";
  8251. push @event, "3:state:T: $temp F: $fanSpeed SP: $setpoint P: $presence U: $voltage";
  8252. } elsif ($st eq "roomSensorControl.1B") {
  8253. # Room Sensor and Control Unit (A5-10-1B)
  8254. # [untested]
  8255. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8256. # $db[3] > 0xFA is error code
  8257. # $db[2] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8258. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8259. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8260. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8261. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8262. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8263. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8264. my $lux = $db[2] << 2;
  8265. if ($db[2] == 251) {$lux = "over range";}
  8266. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8267. my $fanSpeed;
  8268. if ((($db[0] & 0x70) >> 4) == 0) {
  8269. $fanSpeed = "auto";
  8270. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8271. $fanSpeed = "off";
  8272. } else {
  8273. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8274. }
  8275. my $presence;
  8276. if ($db[0] & 2) {
  8277. $presence = "disabled";
  8278. } else {
  8279. $presence = $db[0] & 1 ? "absent" : "present";
  8280. }
  8281. push @event, "3:brightness:$lux";
  8282. push @event, "3:fan:$fanSpeed";
  8283. push @event, "3:presence:$presence";
  8284. push @event, "3:temperature:$temp";
  8285. push @event, "3:voltage:$voltage";
  8286. push @event, "3:state:T: $temp B: $lux F: $fanSpeed P: $presence U: $voltage";
  8287. } elsif ($st eq "roomSensorControl.1C") {
  8288. # Room Sensor and Control Unit (A5-10-1C)
  8289. # [untested]
  8290. # $db[3] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8291. # $db[2] is the illuminance setpoint where min 0x00 = 0 lx, max 0xFA = 1000 lx
  8292. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8293. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8294. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8295. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8296. my $lux = $db[3] << 2;
  8297. if ($db[3] == 251) {$lux = "over range";}
  8298. my $setpoint = $db[2] << 2;
  8299. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8300. my $fanSpeed;
  8301. if ((($db[0] & 0x70) >> 4) == 0) {
  8302. $fanSpeed = "auto";
  8303. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8304. $fanSpeed = "off";
  8305. } else {
  8306. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8307. }
  8308. my $presence;
  8309. if ($db[0] & 2) {
  8310. $presence = "disabled";
  8311. } else {
  8312. $presence = $db[0] & 1 ? "absent" : "present";
  8313. }
  8314. push @event, "3:brightness:$lux";
  8315. push @event, "3:fan:$fanSpeed";
  8316. push @event, "3:presence:$presence";
  8317. push @event, "3:setpoint:$setpoint";
  8318. push @event, "3:temperature:$temp";
  8319. push @event, "3:state:T: $temp B: $lux F: $fanSpeed SP: $setpoint P: $presence";
  8320. } elsif ($st eq "roomSensorControl.1D") {
  8321. # Room Sensor and Control Unit (A5-10-1D)
  8322. # [untested]
  8323. # $db[3] is the humidity where min 0x00 = 0 %rH, max 0xFA = 10 %rH
  8324. # $db[2] is the humidity setpoint where min 0x00 = 0 %rH, max 0xFA = 10 %rH
  8325. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8326. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8327. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8328. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8329. my $humi = sprintf "%d", $db[3] / 2.5;
  8330. my $setpoint = $db[2] / 2.5;
  8331. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8332. my $fanSpeed;
  8333. if ((($db[0] & 0x70) >> 4) == 0) {
  8334. $fanSpeed = "auto";
  8335. } elsif ((($db[0] & 0x70) >> 4) == 7) {
  8336. $fanSpeed = "off";
  8337. } else {
  8338. $fanSpeed = (($db[0] & 0x70) >> 4) - 1;
  8339. }
  8340. my $presence;
  8341. if ($db[0] & 2) {
  8342. $presence = "disabled";
  8343. } else {
  8344. $presence = $db[0] & 1 ? "absent" : "present";
  8345. }
  8346. push @event, "3:fan:$fanSpeed";
  8347. push @event, "3:humidity:$humi";
  8348. push @event, "3:presence:$presence";
  8349. push @event, "3:setpoint:$setpoint";
  8350. push @event, "3:temperature:$temp";
  8351. push @event, "3:state:T: $temp H: $humi F: $fanSpeed SP: $setpoint P: $presence";
  8352. } elsif ($st eq "roomSensorControl.1F") {
  8353. # Room Sensor and Control Unit (A5-10-1F)
  8354. # [untested]
  8355. # $db[3] is the fan speed
  8356. # $db[2] is the setpoint where 0 = 0 ... 255 = 255
  8357. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8358. # $db[0]_bit_6 ... $db[0]_bit_4 is the fan speed
  8359. # $db[0]_bit_6 ... $db[0]_bit_4 are flags
  8360. # $db[0]_bit_1 is Occupany enable where 0 = enabled, 1 = disabled
  8361. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8362. my $fanSpeed = "unknown";
  8363. if ($db[0] & 0x10) {
  8364. $fanSpeed = 3;
  8365. $fanSpeed = 2 if ($db[3] >= 145);
  8366. $fanSpeed = 1 if ($db[3] >= 165);
  8367. $fanSpeed = 0 if ($db[3] >= 190);
  8368. $fanSpeed = "auto" if ($db[3] >= 210);
  8369. }
  8370. my $setpoint = "unknown";
  8371. $setpoint = $db[2] if ($db[0] & 0x20);
  8372. my $temp = "unknown";
  8373. $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250 if ($db[0] & 0x40);
  8374. my $presence = "unknown";
  8375. $presence = "absent" if (!($db[0] & 2));
  8376. $presence = "present" if (!($db[0] & 1));
  8377. push @event, "3:fan:$fanSpeed";
  8378. push @event, "3:presence:$presence";
  8379. push @event, "3:setpoint:$setpoint";
  8380. push @event, "3:temperature:$temp";
  8381. push @event, "3:state:T: $temp F: $fanSpeed SP: $setpoint P: $presence";
  8382. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[2], 0, 255);
  8383. if (defined $setpointScaled) {
  8384. push @event, "3:setpointScaled:" . $setpointScaled;
  8385. }
  8386. } elsif ($st eq "roomSensorControl.20") {
  8387. # Room Operation Panel (A5-10-20, A5-10-21)
  8388. # [untested]
  8389. # $db[3] is the setpoint where 0 = 0 ... 255 = 255
  8390. # $db[2] is the humidity setpoint where min 0x00 = 0 %rH, max 0xFA = 100 %rH
  8391. # $db[1] is the temperature where 250 = 0 °C ... 0 = 40 °C
  8392. # $db[0]_bit_6 ... $db[0]_bit_5 is setpoint mode
  8393. # $db[0]_bit_4 is battery state 0 = ok, 1 = low
  8394. # $db[0]_bit_0 is user activity where 0 = no, 1 = yes
  8395. my $humi = sprintf "%d", $db[2] / 2.5;
  8396. my $setpoint = $db[3];
  8397. my $temp = sprintf "%0.1f", 40 - $db[1] * 40 / 250;
  8398. my $setpointMode;
  8399. if ((($db[0] & 0x60) >> 5) == 3) {
  8400. $setpointMode = "reserved";
  8401. } elsif ((($db[0] & 0x60) >> 5) == 2) {
  8402. $setpointMode = "auto";
  8403. } elsif ((($db[0] & 0x60) >> 1) == 1){
  8404. $setpointMode = "frostProtection";
  8405. } else {
  8406. $setpointMode = "setpoint";
  8407. }
  8408. my $battery = ($db[0] & 0x10) ? "low" : "ok";
  8409. push @event, "3:activity:" . ($db[0] & 1 ? "yes" : "no");
  8410. push @event, "3:battery:$battery";
  8411. push @event, "3:humidity:$humi";
  8412. push @event, "3:setpoint:$setpoint";
  8413. push @event, "3:setpointMode:$setpointMode";
  8414. push @event, "3:temperature:$temp";
  8415. push @event, "3:state:T: $temp H: $humi SP: $setpoint B: $battery";
  8416. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[3], 0, 255);
  8417. if (defined $setpointScaled) {
  8418. push @event, "3:setpointScaled:" . $setpointScaled;
  8419. }
  8420. } elsif ($st eq "roomSensorControl.22") {
  8421. # Room Operation Panel (A5-10-22, A5-10-23)
  8422. my $setpoint = $db[3];
  8423. my $humi = sprintf "%d", $db[2] / 2.5;
  8424. my $temp = sprintf "%0.1f", $db[1] * 40 / 250;
  8425. my $fanSpeed;
  8426. if ((($db[0] & 0xE0) >> 5) == 4) {
  8427. $fanSpeed = 3;
  8428. } elsif ((($db[0] & 0xE0) >> 5) == 3) {
  8429. $fanSpeed = 2;
  8430. } elsif ((($db[0] & 0xE0) >> 5) == 2) {
  8431. $fanSpeed = 1;
  8432. } elsif ((($db[0] & 0xE0) >> 5) == 1){
  8433. $fanSpeed = "off";
  8434. } else {
  8435. $fanSpeed = "auto";
  8436. }
  8437. my $occupancy = ($db[0] & 1) ? "occupied" : "unoccupied";
  8438. push @event, "3:occupancy:$occupancy";
  8439. push @event, "3:humidity:$humi";
  8440. push @event, "3:setpoint:$setpoint";
  8441. push @event, "3:fanSpeed:$fanSpeed";
  8442. push @event, "3:temperature:$temp";
  8443. push @event, "3:state:T: $temp H: $humi SP: $setpoint F: $fanSpeed O: $occupancy";
  8444. my $setpointScaled = EnOcean_ReadingScaled($hash, $db[3], 0, 255);
  8445. if (defined $setpointScaled) {
  8446. push @event, "3:setpointScaled:" . $setpointScaled;
  8447. }
  8448. } elsif ($st eq "tempHumiSensor.02") {
  8449. # Temperatur and Humidity Sensor(EEP A5-04-02)
  8450. # [Eltako FAFT60, FIFT63AP]
  8451. # $db[3] is the voltage where 0x59 = 2.5V ... 0x9B = 4V, only at Eltako
  8452. # $db[2] is the humidity where 0x00 = 0%rH ... 0xFA = 100%rH
  8453. # $db[1] is the temperature where 0x00 = -20°C ... 0xFA = +60°C
  8454. my $humi = sprintf "%d", $db[2] / 2.5;
  8455. my $temp = sprintf "%0.1f", -20 + $db[1] * 80 / 250;
  8456. my $battery = "unknown";
  8457. if ($manufID eq "00D") {
  8458. # Eltako sensor
  8459. my $voltage = sprintf "%0.1f", $db[3] * 6.58 / 255;
  8460. my $energyStorage = "unknown";
  8461. if ($db[3] <= 0x58) {
  8462. $energyStorage = "empty";
  8463. $battery = "low";
  8464. }
  8465. elsif ($db[3] <= 0xDC) {
  8466. $energyStorage = "charged";
  8467. $battery = "ok";
  8468. }
  8469. else {
  8470. $energyStorage = "full";
  8471. $battery = "ok";
  8472. }
  8473. push @event, "3:battery:$battery";
  8474. push @event, "3:energyStorage:$energyStorage";
  8475. push @event, "3:voltage:$voltage";
  8476. }
  8477. push @event, "3:state:T: $temp H: $humi B: $battery";
  8478. push @event, "3:humidity:$humi";
  8479. push @event, "3:temperature:$temp";
  8480. } elsif ($st eq "tempHumiSensor.03") {
  8481. # Temperatur and Humidity Sensor(EEP A5-04-03)
  8482. # [untested]
  8483. # $db[3] is the humidity where 0x00 = 0%rH ... 0xFF = 100%rH
  8484. # $db[2] .. $db[1] is the temperature where 0x00 = -20°C ... 0x3FF = +60°C
  8485. my $humi = sprintf "%d", $db[3] / 2.55;
  8486. my $temp = sprintf "%0.1f", -20 + ($db[2] << 8 | $db[1]) * 80 / 1023;
  8487. push @event, "3:state:T: $temp H: $humi";
  8488. push @event, "3:humidity:$humi";
  8489. push @event, "3:temperature:$temp";
  8490. push @event, "3:telegramType:" . ($db[0] & 1 ? "event" : "heartbeat");
  8491. } elsif ($st eq "baroSensor.01") {
  8492. # Barometric Sensor(EEP A5-04-03)
  8493. # [untested]
  8494. # $db[3] .. $db[2] is the barometric where 0x00 = 500 hPa ... 0x3FF = 1150 hPa
  8495. my $baro = sprintf "%d", 500 + ($db[2] << 8 | $db[1]) * 650 / 1023;
  8496. push @event, "3:state:$baro";
  8497. push @event, "3:airPressure:$baro";
  8498. push @event, "3:telegramType:" . ($db[0] & 1 ? "event" : "heartbeat");
  8499. } elsif ($st eq "lightSensor.01") {
  8500. # Light Sensor (EEP A5-06-01)
  8501. # [Eltako FAH60, FAH63, FIH63, Thermokon SR65 LI, untested]
  8502. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8503. # $db[3] is the low illuminance for Eltako devices where
  8504. # min 0x00 = 0 lx, max 0xFF = 100 lx, if $db[2] = 0
  8505. # $db[2] is the illuminance (ILL2) where min 0x00 = 300 lx, max 0xFF = 30000 lx
  8506. # $db[1] is the illuminance (ILL1) where min 0x00 = 600 lx, max 0xFF = 60000 lx
  8507. # $db[0]_bit_0 is Range select where 0 = ILL1, 1 = ILL2
  8508. my $lux;
  8509. my $voltage = "unknown";
  8510. if ($manufID eq "00D") {
  8511. if($db[2] == 0) {
  8512. $lux = sprintf "%d", $db[3] * 100 / 255;
  8513. } else {
  8514. $lux = sprintf "%d", $db[2] * 116.48 + 300;
  8515. }
  8516. } else {
  8517. $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8518. if($db[0] & 1) {
  8519. $lux = sprintf "%d", $db[2] * 116.48 + 300;
  8520. } else {
  8521. $lux = sprintf "%d", $db[1] * 232.94 + 600;
  8522. }
  8523. push @event, "3:voltage:$voltage";
  8524. }
  8525. push @event, "3:brightness:$lux";
  8526. push @event, "3:state:$lux";
  8527. } elsif ($st eq "lightSensor.02") {
  8528. # Light Sensor (EEP A5-06-02)
  8529. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8530. # $db[2] is the illuminance (ILL2) where min 0x00 = 0 lx, max 0xFF = 510 lx
  8531. # $db[1] is the illuminance (ILL1) where min 0x00 = 0 lx, max 0xFF = 1020 lx
  8532. # $db[0]_bit_0 is Range select where 0 = ILL1, 1 = ILL2
  8533. my $lux;
  8534. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8535. if($db[0] & 1) {
  8536. $lux = $db[2] << 1;
  8537. } else {
  8538. $lux = $db[1] << 2;
  8539. }
  8540. push @event, "3:voltage:$voltage";
  8541. push @event, "3:brightness:$lux";
  8542. push @event, "3:state:$lux";
  8543. } elsif ($st eq "lightSensor.03") {
  8544. # Light Sensor (EEP A5-06-03)
  8545. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8546. # $db[3] > 0xFA is error code
  8547. # $db[2]_bit_7 ... $db[1]_bit_6 is the illuminance where min 0x000 = 0 lx, max 0x3E8 = 1000 lx
  8548. my $lux = $db[2] << 2 | $db[1] >> 6;
  8549. if ($lux == 1001) {$lux = "over range";}
  8550. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8551. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8552. push @event, "3:voltage:$voltage";
  8553. push @event, "3:brightness:$lux";
  8554. push @event, "3:state:$lux";
  8555. } elsif ($st eq "lightSensor.04") {
  8556. # Light Sensor (EEP A5-06-04)
  8557. my $temperature;
  8558. if ($db[0] & 2) {
  8559. $temperature = sprintf "%0.1f", $db[3] * 80 / 255 - 20;
  8560. push @event, "3:temperature:$temperature";
  8561. } else {
  8562. $temperature = '-';
  8563. CommandDeleteReading(undef, "$name temperature");
  8564. }
  8565. my $brightness;
  8566. if ($db[0] & 1) {
  8567. $brightness = $db[2] << 8 | $db[1];
  8568. push @event, "3:brightness:$brightness";
  8569. } else {
  8570. $brightness = '-';
  8571. CommandDeleteReading(undef, "$name brightness");
  8572. }
  8573. my $energyStorage = sprintf "%d", ($db[0] >> 4) * 100 / 15;
  8574. my $battery;
  8575. if ($energyStorage <= 6) {
  8576. $battery = 'low';
  8577. push @event, "3:battery:low";
  8578. push @event, "3:energyStorage:$energyStorage";
  8579. } else {
  8580. $battery = 'ok';
  8581. push @event, "3:battery:ok";
  8582. push @event, "3:energyStorage:$energyStorage";
  8583. }
  8584. push @event, "3:state:T: $temperature E: $brightness B: $battery";
  8585. } elsif ($st eq "lightSensor.05") {
  8586. # Light Sensor (EEP A5-06-05)
  8587. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8588. # $db[2] is the illuminance (ILL2) where min 0x00 = 0 lx, max 0xFF = 5100 lx
  8589. # $db[1] is the illuminance (ILL1) where min 0x00 = 0 lx, max 0xFF = 1020000 lx
  8590. # $db[0]_bit_0 is Range select where 0 = ILL1, 1 = ILL2
  8591. my $lux;
  8592. if($db[0] & 1) {
  8593. $lux = sprintf "%d", $db[2] * 20;
  8594. } else {
  8595. $lux = sprintf "%d", $db[1] * 40;
  8596. }
  8597. push @event, "3:voltage:" . sprintf "%0.1f", $db[3] * 0.02;
  8598. push @event, "3:brightness:$lux";
  8599. push @event, "3:state:$lux";
  8600. } elsif ($st eq "occupSensor.01") {
  8601. # Occupancy Sensor (EEP A5-07-01)
  8602. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8603. # $db[3] > 0xFA is error code
  8604. # $db[2] is solar panel current where =0 uA ... 0xFF = 127 uA
  8605. # $db[1] is PIR Status (motion) where 0 ... 127 = off, 128 ... 255 = on
  8606. my $motion = "off";
  8607. if ($db[1] >= 128) {$motion = "on";}
  8608. if ($db[0] & 1) {push @event, "3:voltage:" . sprintf "%0.1f", $db[3] * 0.02;}
  8609. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8610. if ($manufID eq "00B") {
  8611. push @event, "3:current:" . sprintf "%0.1f", $db[2] / 2;
  8612. if ($db[0] & 2) {
  8613. push @event, "3:sensorType:ceiling";
  8614. } else {
  8615. push @event, "3:sensorType:wall";
  8616. }
  8617. }
  8618. if ($model eq "tracker") {
  8619. @{$hash->{helper}{motionTimer}} = ($hash, 'motion', 'off', 1, 5);
  8620. @{$hash->{helper}{stateTimer}} = ($hash, 'state', 'off', 1, 5);
  8621. RemoveInternalTimer($hash->{helper}{motionTimer});
  8622. RemoveInternalTimer($hash->{helper}{stateTimer});
  8623. InternalTimer(gettimeofday() + AttrVal($name, 'trackerWakeUpCycle', 30) * 1.1, 'EnOcean_readingsSingleUpdate', $hash->{helper}{motionTimer}, 0);
  8624. InternalTimer(gettimeofday() + AttrVal($name, 'trackerWakeUpCycle', 30) * 1.1, 'EnOcean_readingsSingleUpdate', $hash->{helper}{stateTimer}, 0);
  8625. }
  8626. if (!exists($hash->{helper}{lastVoltage}) || $hash->{helper}{lastVoltage} != $db[3]) {
  8627. push @event, "3:battery:" . ($db[3] * 0.02 > 2.8 ? "ok" : "low");
  8628. $hash->{helper}{lastVoltage} = $db[3];
  8629. }
  8630. push @event, "3:button:" . ($db[0] & 4 ? "released" : "pressed") if ($manufID eq "7FF");
  8631. push @event, "3:motion:$motion";
  8632. push @event, "3:state:$motion";
  8633. } elsif ($st eq "occupSensor.02") {
  8634. # Occupancy Sensor (EEP A5-07-02)
  8635. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8636. # $db[3] > 0xFA is error code
  8637. # $db[0]_bit_7 is PIR Status (motion) where 0 = off, 1 = on
  8638. my $motion = $db[0] >> 7 ? "on" : "off";
  8639. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8640. push @event, "3:battery:" . ($db[3] * 0.02 > 2.9 ? "ok" : "low");
  8641. push @event, "3:motion:$motion";
  8642. push @event, "3:voltage:" . sprintf "%0.1f", $db[3] * 0.02;
  8643. push @event, "3:state:$motion";
  8644. } elsif ($st eq "occupSensor.03") {
  8645. # Occupancy Sensor (EEP A5-07-03)
  8646. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  8647. # $db[3] > 0xFA is error code
  8648. # $db[2]_bit_7 ... $db[1]_bit_6 is the illuminance where min 0x000 = 0 lx, max 0x3E8 = 1000 lx
  8649. # $db[0]_bit_7 is PIR Status (motion) where 0 = off, 1 = on
  8650. my $motion = $db[0] >> 7 ? "on" : "off";
  8651. my $lux = $db[2] << 2 | $db[1] >> 6;
  8652. if ($lux == 1001) {$lux = "over range";}
  8653. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8654. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  8655. push @event, "3:battery:" . ($db[3] * 0.02 > 2.9 ? "ok" : "low");
  8656. push @event, "3:brightness:$lux";
  8657. push @event, "3:motion:$motion";
  8658. push @event, "3:voltage:$voltage";
  8659. push @event, "3:state:M: $motion E: $lux U: $voltage";
  8660. } elsif ($st =~ m/^lightTempOccupSensor/) {
  8661. # Light, Temperatur and Occupancy Sensor (EEP A5-08-01 ... A5-08-03)
  8662. # $db[3] is the voltage where 0x00 = 0 V ... 0xFF = 5.1 V
  8663. # $db[2] is the illuminance where min 0x00 = 0 lx, max 0xFF = 510 lx, 1020 lx, (2048 lx)
  8664. # $db[1] is the temperature whrere 0x00 = 0 °C ... 0xFF = 51 °C or -30 °C ... 50°C
  8665. # $db[0]_bit_1 is PIR Status (motion) where 0 = on, 1 = off
  8666. # $db[0]_bit_0 is Occupany Button where 0 = pressed, 1 = released
  8667. my $lux;
  8668. my $temp;
  8669. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  8670. my $motion = $db[0] & 2 ? "off" : "on";
  8671. my $presence = $db[0] & 1 ? "absent" : "present";
  8672. if ($st eq "lightTempOccupSensor.01") {
  8673. # Light, Temperatur and Occupancy Sensor (EEP A5-08-01)
  8674. # [Eltako FABH63, FBH55, FBH63, FIBH63]
  8675. if ($manufID eq "00D") {
  8676. $lux = sprintf "%d", $db[2] * 2048 / 255;
  8677. push @event, "3:state:M: $motion E: $lux";
  8678. } else {
  8679. $lux = $db[2] << 1;
  8680. $temp = sprintf "%0.1f", $db[1] * 0.2;
  8681. push @event, "3:state:M: $motion E: $lux P: $presence T: $temp U: $voltage";
  8682. push @event, "3:presence:$presence";
  8683. push @event, "3:temperature:$temp";
  8684. push @event, "3:voltage:$voltage";
  8685. }
  8686. } elsif ($st eq "lightTempOccupSensor.02") {
  8687. # Light, Temperatur and Occupancy Sensor (EEP A5-08-02)
  8688. $lux = $db[2] << 2;
  8689. $temp = sprintf "%0.1f", $db[1] * 0.2;
  8690. push @event, "3:state:M: $motion E: $lux P: $presence T: $temp U: $voltage";
  8691. push @event, "3:presence:$presence";
  8692. push @event, "3:temperature:$temp";
  8693. push @event, "3:voltage:$voltage";
  8694. } elsif ($st eq "lightTempOccupSensor.03") {
  8695. # Light, Temperatur and Occupancy Sensor (EEP A5-08-03)
  8696. $lux = $db[2] * 6;
  8697. $temp = sprintf "%0.1f", -30 + $db[1] * 80 / 255;
  8698. push @event, "3:state:M: $motion E: $lux P: $presence T: $temp U: $voltage";
  8699. push @event, "3:presence:$presence";
  8700. push @event, "3:temperature:$temp";
  8701. push @event, "3:voltage:$voltage";
  8702. }
  8703. push @event, "3:brightness:$lux";
  8704. push @event, "3:motion:$motion";
  8705. } elsif ($st eq "lightCtrlState.01") {
  8706. # Lighting Controller State (EEP A5-11-01)
  8707. # $db[3] is the illumination where 0x00 = 0 lx ... 0xFF = 510 lx
  8708. # $db[2] is the illumination Setpoint where 0x00 = 0 ... 0xFF = 255
  8709. # $db[1] is the Dimming Output Level where 0x00 = 0 ... 0xFF = 255
  8710. # $db[0]_bit_7 is the Repeater state where 0 = disabled, 1 = enabled
  8711. # $db[0]_bit_6 is the Power Relay Timer state where 0 = disabled, 1 = enabled
  8712. # $db[0]_bit_5 is the Daylight Harvesting state where 0 = disabled, 1 = enabled
  8713. # $db[0]_bit_4 is the Dimming mode where 0 = switching, 1 = dimming
  8714. # $db[0]_bit_2 is the Magnet Contact state where 0 = open, 1 = closed
  8715. # $db[0]_bit_1 is the Occupancy (prensence) state where 0 = absent, 1 = present
  8716. # $db[0]_bit_0 is the Power Relay state where 0 = off, 1 = on
  8717. push @event, "3:brightness:" . ($db[3] << 1);
  8718. push @event, "3:illum:$db[2]";
  8719. push @event, "3:dim:$db[1]";
  8720. push @event, "3:powerRelayTimer:" . ($db[0] & 0x80 ? "enabled" : "disabled");
  8721. push @event, "3:repeater:" . ($db[0] & 0x40 ? "enabled" : "disabled");
  8722. push @event, "3:daylightHarvesting:" . ($db[0] & 0x20 ? "enabled" : "disabled");
  8723. push @event, "3:mode:" . ($db[0] & 0x10 ? "dimming" : "switching");
  8724. push @event, "3:contact:" . ($db[0] & 4 ? "closed" : "open");
  8725. push @event, "3:presence:" . ($db[0] & 2 ? "present" : "absent");
  8726. push @event, "3:powerSwitch:" . ($db[0] & 1 ? "on" : "off");
  8727. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  8728. } elsif ($st eq "tempCtrlState.01") {
  8729. # Temperature Controller Output (EEP A5-11-02)
  8730. # $db[3] is the Control Variable where 0x00 = 0 % ... 0xFF = 100 %
  8731. # $db[2] is the Fan Stage
  8732. # $db[1] is the Actual Setpoint where 0x00 = 0 °C ... 0xFF = 51.2 °C
  8733. # $db[0]_bit_7 is the Alarm state where 0 = no, 1 = yes
  8734. # $db[0]_bit_6 ... $db[0]_bit_5 is the Controller Mode
  8735. # $db[0]_bit_4 is the Controller State where 0 = auto, 1 = override
  8736. # $db[0]_bit_2 is the Energy hold-off where 0 = normal, 1 = hold-off
  8737. # $db[0]_bit_1 ... $db[0]_bit_0is the Occupancy (prensence) state where 0 = present
  8738. # 1 = absent, 3 = standby, 4 = frost
  8739. push @event, "3:controlVar:" . sprintf "%d", $db[3] * 100 / 255;
  8740. if (($db[2] & 3) == 0) {
  8741. push @event, "3:fan:0";
  8742. } elsif (($db[2] & 3) == 1){
  8743. push @event, "3:fan:1";
  8744. } elsif (($db[2] & 3) == 2){
  8745. push @event, "3:fan:2";
  8746. } elsif (($db[2] & 3) == 3){
  8747. push @event, "3:fan:3";
  8748. } elsif ($db[2] == 255){
  8749. push @event, "3:fan:unknown";
  8750. }
  8751. push @event, "3:fanMode:" . ($db[2] & 0x10 ? "auto" : "manual");
  8752. my $setpointTemp = sprintf "%0.1f", $db[1] * 0.2;
  8753. push @event, "3:setpointTemp:$setpointTemp";
  8754. push @event, "3:alarm:" . ($db[0] & 1 ? "on" : "off");
  8755. my $controllerMode = ($db[0] & 0x60) >> 5;
  8756. if ($controllerMode == 0) {
  8757. push @event, "3:controllerMode:auto";
  8758. } elsif ($controllerMode == 1) {
  8759. push @event, "3:controllerMode:heating";
  8760. } elsif ($controllerMode == 2) {
  8761. push @event, "3:controllerMode:cooling";
  8762. } elsif ($controllerMode == 3) {
  8763. push @event, "3:controllerMode:off";
  8764. }
  8765. push @event, "3:controllerState:" . ($db[0] & 0x10 ? "override" : "auto");
  8766. push @event, "3:energyHoldOff:" . ($db[0] & 4 ? "holdoff" : "normal");
  8767. if (($db[0] & 3) == 0) {
  8768. push @event, "3:presence:present";
  8769. } elsif (($db[0] & 3) == 1){
  8770. push @event, "3:presence:absent";
  8771. } elsif (($db[0] & 3) == 2){
  8772. push @event, "3:presence:standby";
  8773. } elsif (($db[0] & 3) == 3){
  8774. push @event, "3:presence:frost";
  8775. }
  8776. push @event, "3:state:$setpointTemp";
  8777. } elsif ($st eq "shutterCtrlState.01") {
  8778. # Blind Status (EEP A5-11-03)
  8779. # $db[3] is the Shutter Position where 0 = 0 % ... 100 = 100 %
  8780. # $db[2]_bit_7 is the Angle sign where 0 = positive, 1 = negative
  8781. # $db[2]_bit_6 ... $db[2]_bit_0 where 0 = 0° ... 90 = 180°
  8782. # $db[1]_bit_7 is the Position Value Flag where 0 = no available, 1 = available
  8783. # $db[1]_bit_6 is the Angle Value Flag where 0 = no available, 1 = available
  8784. # $db[1]_bit_5 ... $db[1]_bit_4 is the Error State (alarm)
  8785. # $db[1]_bit_3 ... $db[1]_bit_2 is the End-position State
  8786. # $db[1]_bit_1 ... $db[1]_bit_0 is the Shutter State
  8787. # $db[0]_bit_7 is the Service Mode where 0 = no, 1 = yes
  8788. # $db[0]_bit_6 is the Position Mode where 0 = normal, 1 = inverse
  8789. if ($db[1] & 0x80) {
  8790. push @event, "3:position:" . $db[3];
  8791. }
  8792. my $anglePos = ($db[2] & 0x7F) << 1;
  8793. if ($db[2] & 0x80) {$anglePos *= -1;}
  8794. if ($db[1] & 0x40) {
  8795. push @event, "3:anglePos:" . $anglePos;
  8796. }
  8797. my $alarm = ($db[1] & 0x30) >> 4;
  8798. if ($alarm == 0) {
  8799. push @event, "3:alarm:off";
  8800. } elsif ($alarm == 1){
  8801. push @event, "3:alarm:no_endpoints_defined";
  8802. } elsif ($alarm == 2){
  8803. push @event, "3:alarm:on";
  8804. } elsif ($alarm == 3){
  8805. push @event, "3:alarm:not_used";
  8806. }
  8807. my $endPosition = ($db[1] & 0x0C) >> 2;
  8808. if ($endPosition == 0) {
  8809. push @event, "3:endPosition:not_available";
  8810. push @event, "3:state:not_available";
  8811. } elsif ($endPosition == 1) {
  8812. push @event, "3:endPosition:not_reached";
  8813. push @event, "3:state:not_reached";
  8814. } elsif ($endPosition == 2) {
  8815. push @event, "3:endPosition:open";
  8816. push @event, "3:state:open";
  8817. } elsif ($endPosition == 3){
  8818. push @event, "3:endPosition:closed";
  8819. push @event, "3:state:closed";
  8820. }
  8821. my $shutterState = $db[1] & 3;
  8822. if (($db[1] & 3) == 0) {
  8823. push @event, "3:shutterState:not_available";
  8824. } elsif (($db[1] & 3) == 1) {
  8825. push @event, "3:shutterState:stopped";
  8826. } elsif (($db[1] & 3) == 2){
  8827. push @event, "3:shutterState:opens";
  8828. } elsif (($db[1] & 3) == 3){
  8829. push @event, "3:shutterState:closes";
  8830. }
  8831. push @event, "3:serviceOn:" . ($db[0] & 0x80 ? "yes" : "no");
  8832. push @event, "3:positionMode:" . ($db[0] & 0x40 ? "inverse" : "normal");
  8833. } elsif ($st eq "lightCtrlState.02") {
  8834. # Extended Lighting Status (EEP A5-11-04)
  8835. # $db[3] the contents of the variable depends on the parameter mode
  8836. # $db[2] the contents of the variable depends on the parameter mode
  8837. # $db[1] the contents of the variable depends on the parameter mode
  8838. # $db[0]_bit_7 is the Service Mode where 0 = no, 1 = yes
  8839. # $db[0]_bit_6 is the operating hours flag where 0 = not_available, 1 = available
  8840. # $db[0]_bit_5 ... $db[0]_bit_4 is the Error State (alarm)
  8841. # $db[0]_bit_2 ... $db[0]_bit_1 is the parameter mode
  8842. # $db[0]_bit_0 is the lighting status where 0 = off, 1 = on
  8843. push @event, "3:serviceOn:" . ($db[1] & 0x80 ? "yes" : "no");
  8844. my $alarm = ($db[0] & 0x30) >> 4;
  8845. if ($alarm == 0) {
  8846. push @event, "3:alarm:off";
  8847. } elsif ($alarm == 1){
  8848. push @event, "3:alarm:lamp_failure";
  8849. } elsif ($alarm == 2){
  8850. push @event, "3:alarm:internal_failure";
  8851. } elsif ($alarm == 3){
  8852. push @event, "3:alarm:external_periphery_failure";
  8853. }
  8854. my $mode = ($db[0] & 6) >> 1;
  8855. if ($mode == 0) {
  8856. # dimmer value and lamp operating hours
  8857. push @event, "3:dim:$db[3]";
  8858. if ($db[0] & 40) {
  8859. push @event, "3:lampOpHours:" . ($db[2] << 8 | $db[1]);
  8860. } else {
  8861. push @event, "3:lampOpHours:unknown";
  8862. }
  8863. } elsif ($mode == 1){
  8864. # RGB value
  8865. push @event, "3:red:$db[3]";
  8866. push @event, "3:green:$db[2]";
  8867. push @event, "3:blue:$db[1]";
  8868. push @event, "3:rgb:" . substr($data, 0, 6);
  8869. } elsif ($mode == 2){
  8870. # energy metering value
  8871. my @measureUnit = ("mW", "W", "kW", "MW", "Wh", "kWh", "MWh", "GWh",
  8872. "mA", "A", "mV", "V");
  8873. if ($db[1] < 4) {
  8874. push @event, "3:power:" . ($db[3] << 8 | $db[2]);
  8875. push @event, "3:powerUnit:" . $measureUnit[$db[1]];
  8876. } elsif ($db[1] < 8) {
  8877. push @event, "3:energy:" . ($db[3] << 8 | $db[2]);
  8878. push @event, "3:energyUnit:" . $measureUnit[$db[1]];
  8879. } elsif ($db[1] == 8) {
  8880. push @event, "3:current:" . ($db[3] << 8 | $db[2]);
  8881. push @event, "3:currentUnit:" . $measureUnit[$db[1]];
  8882. } elsif ($db[1] == 9) {
  8883. push @event, "3:current:" . sprintf "%0.1f", ($db[3] << 8 | $db[2]) / 10;
  8884. push @event, "3:currentUnit:" . $measureUnit[$db[1]];
  8885. } elsif ($db[1] == 10) {
  8886. push @event, "3:voltage:" . ($db[3] << 8 | $db[2]);
  8887. push @event, "3:voltageUnit:" . $measureUnit[$db[1]];
  8888. } elsif ($db[1] == 11) {
  8889. push @event, "3:voltage:" . sprintf "%0.1f", ($db[3] << 8 | $db[2]) / 10;
  8890. push @event, "3:voltageUnit:" . $measureUnit[$db[1]];
  8891. } else {
  8892. push @event, "3:measuredValue:" . ($db[3] << 8 | $db[2]);
  8893. push @event, "3:measureUnit:unknown";
  8894. }
  8895. } elsif ($mode == 3){
  8896. # not used
  8897. }
  8898. push @event, "3:powerSwitch:" . ($db[0] & 1 ? "on" : "off");
  8899. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  8900. } elsif ($st eq "switch.05") {
  8901. # Dual Channel Switch Actuator
  8902. # (A5-11-05)
  8903. if ($db[0] & 1) {
  8904. push @event, "3:workingMode:" . (($db[0] & 0x70) >> 4);
  8905. push @event, "3:channel1:" . ($db[0] & 2 ? "on" : "off");
  8906. push @event, "3:channel2:" . ($db[0] & 4 ? "on" : "off");
  8907. push @event, "3:state:1: " . ($db[0] & 2 ? "on" : "off") . " 2: " . ($db[0] & 4 ? "on" : "off");
  8908. }
  8909. } elsif ($st =~ m/^autoMeterReading\.0[0-3]$/ || $st eq "actuator.01" && $manufID eq "033") {
  8910. # Automated meter reading (AMR) (EEP A5-12-00 ... A5-12-03)
  8911. # $db[3] (MSB) + $db[2] + $db[1] (LSB) is the Meter reading
  8912. # $db[0]_bit_7 ... $db[0]_bit_4 is the Measurement channel
  8913. # $db[0]_bit_2 is the Data type where 0 = cumulative value, 1 = current value
  8914. # $db[0]_bit_1 ... $db[0]_bit_0 is the Divisor where 0 = x/1, 1 = x/10,
  8915. # 2 = x/100, 3 = x/1000
  8916. my $dataType = ($db[0] & 4) >> 2;
  8917. my $divisor = $db[0] & 3;
  8918. my $meterReading;
  8919. if ($divisor == 3) {
  8920. $meterReading = sprintf "%.3f", ($db[3] << 16 | $db[2] << 8 | $db[1]) / 1000;
  8921. } elsif ($divisor == 2) {
  8922. $meterReading = sprintf "%.2f", ($db[3] << 16 | $db[2] << 8 | $db[1]) / 100;
  8923. } elsif ($divisor == 1) {
  8924. $meterReading = sprintf "%.1f", ($db[3] << 16 | $db[2] << 8 | $db[1]) / 10;
  8925. } else {
  8926. $meterReading = $db[3] << 16 | $db[2] << 8 | $db[1];
  8927. }
  8928. my $channel = $db[0] >> 4;
  8929. if ($st eq "autoMeterReading.00") {
  8930. # Automated meter reading (AMR), Counter (EEP A5-12-01)
  8931. # [Thermokon SR-MI-HS, untested]
  8932. if ($dataType == 1) {
  8933. # current value
  8934. push @event, "3:currentValue" . sprintf('%02d', $channel) . ":$meterReading";
  8935. push @event, "3:state:$meterReading";
  8936. } else {
  8937. # cumulative counter
  8938. push @event, "3:counter" . sprintf('%02d', $channel) . ":$meterReading";
  8939. }
  8940. } elsif ($st eq "autoMeterReading.01" || $st eq "actuator.01" && $manufID eq "033") {
  8941. # Automated meter reading (AMR), Electricity (EEP A5-12-01)
  8942. # [Eltako FSS12, FWZ12, DSZ14DRS, DSZ14WDRS, DWZ61]
  8943. # $db[0]_bit_7 ... $db[0]_bit_4 is the Tariff info
  8944. # $db[0]_bit_2 is the Data type where 0 = cumulative value kWh,
  8945. # 1 = current value W
  8946. if ($db[0] == 0x8F && $manufID eq "00D") {
  8947. # Eltako, read meter serial number
  8948. my $serialNumber;
  8949. if ($db[1] == 0) {
  8950. # first 2 digits of the serial number
  8951. $serialNumber = substr(ReadingsVal($name, "serialNumber", "S-------"), 4, 4);
  8952. $serialNumber = sprintf "S-%01x%01x%4s", $db[3] >> 4, $db[3] & 0x0F, $serialNumber;
  8953. } else {
  8954. # last 4 digits of the serial number
  8955. $serialNumber = substr(ReadingsVal($name, "serialNumber", "S---"), 0, 4);
  8956. $serialNumber = sprintf "%4s%01x%01x%01x%01x", $serialNumber,
  8957. $db[2] >> 4, $db[2] & 0x0F, $db[3] >> 4, $db[3] & 0x0F;
  8958. }
  8959. push @event, "3:serialNumber:$serialNumber";
  8960. } elsif ($dataType == 1) {
  8961. # momentary power
  8962. push @event, "3:power:$meterReading";
  8963. if (!($st eq "actuator.01" && $manufID eq "033")) {
  8964. push @event, "3:state:$meterReading";
  8965. }
  8966. } else {
  8967. # power consumption
  8968. push @event, "3:energy$channel:$meterReading";
  8969. push @event, "3:currentTariff:$channel";
  8970. }
  8971. } elsif ($st eq "autoMeterReading.02" || $st eq "autoMeterReading.03") {
  8972. # Automated meter reading (AMR), Gas, Water (EEP A5-12-02, A5-12-03)
  8973. if ($dataType == 1) {
  8974. # current value
  8975. push @event, "3:flowrate:$meterReading";
  8976. push @event, "3:state:$meterReading";
  8977. } else {
  8978. # cumulative counter
  8979. push @event, "3:consumption$channel:$meterReading";
  8980. push @event, "3:currentTariff:$channel";
  8981. }
  8982. }
  8983. } elsif ($st =~ m/^autoMeterReading\.0[45]$/) {
  8984. # $db[1] is the temperature 0 .. 0xFF >> -40 ... 40
  8985. # $db[0]_bit_1 ... $db[0]_bit_0 is the battery level
  8986. my $temperature = sprintf "%0.1f", ($db[1] / 255 * 80) - 40;
  8987. my $battery = $db[0] & 3;
  8988. if ($battery == 3) {
  8989. $battery = "empty";
  8990. } elsif ($battery == 2) {
  8991. $battery = "low";
  8992. } elsif ($battery == 1) {
  8993. $battery = "ok";
  8994. } else {
  8995. $battery = "full";
  8996. }
  8997. push @event, "3:battery:$battery";
  8998. push @event, "3:temperature:$temperature";
  8999. if ($st eq "autoMeterReading.04") {
  9000. # Automated meter reading (AMR), Temperature, Load (EEP A5-12-04)
  9001. # $db[3] ... $db[2]_bit_2 is the Current Value in gram
  9002. my $weight = $db[3] << 6 | $db[2];
  9003. push @event, "3:weight:$weight";
  9004. push @event, "3:state:T: $temperature W: $weight B: $battery";
  9005. } elsif ($st eq "autoMeterReading.05") {
  9006. # Automated meter reading (AMR), Temperature, Container (EEP A5-12-05)
  9007. # $db[3] ... $db[2]_bit_6 is position sensor
  9008. my @sp;
  9009. $sp[0] = ($db[3] & 128) >> 7;
  9010. $sp[1] = ($db[3] & 64) >> 6;
  9011. $sp[2] = ($db[3] & 32) >> 5;
  9012. $sp[3] = ($db[3] & 16) >> 4;
  9013. $sp[4] = ($db[3] & 8) >> 3;
  9014. $sp[5] = ($db[3] & 4) >> 2;
  9015. $sp[6] = ($db[3] & 2) >> 1;
  9016. $sp[7] = $db[3] & 1;
  9017. $sp[8] = ($db[2] & 128) >> 7;
  9018. $sp[9] = ($db[2] & 64) >> 6;
  9019. my $amount = 0;
  9020. for (my $spCntr = 0; $spCntr <= 9; $spCntr ++) {
  9021. push @event, "3:location" . $spCntr . ":" . ($sp[$spCntr] ? "possessed" : "not_possessed");
  9022. $amount += $sp[$spCntr];
  9023. }
  9024. push @event, "3:amount:$amount";
  9025. push @event, "3:state:T: $temperature L: " . $sp[0] . $sp[1] . " " . $sp[2] . $sp[3] .
  9026. " " . $sp[4] . $sp[5] . " " . $sp[6] . $sp[7] . " " . $sp[8] . $sp[9] . " B: $battery";
  9027. }
  9028. } elsif ($st eq "autoMeterReading.10") {
  9029. # Automated meter reading (AMR), current meter 16 channels (EEP A5-12-10)
  9030. my $meterReading = hex(substr($data, 0, 6)) / 10 ** ($db[0] & 3);
  9031. my $channel = sprintf '%02d', $db[0] & 0xF0 >> 4;
  9032. my $scaleDecimals = "%0." . ($db[0] & 3) . "f";
  9033. push @event, "3:currentTariff:$channel";
  9034. if ($db[0] & 4) {
  9035. # current
  9036. push @event, "3:current$channel:" . sprintf "$scaleDecimals", $meterReading;
  9037. push @event, "3:state:" . sprintf "$scaleDecimals", $meterReading;
  9038. } else {
  9039. # electric charge
  9040. push @event, "3:electricChange$channel:" . sprintf "$scaleDecimals", $meterReading;
  9041. }
  9042. } elsif ($st eq "environmentApp") {
  9043. # Environmental Applications (EEP A5-13-01 ... EEP A5-13-06, EEP A5-13-10)
  9044. # [Eltako FWS61]
  9045. # $db[0]_bit_7 ... $db[0]_bit_4 is the Identifier
  9046. my $identifier = $db[0] >> 4;
  9047. if ($identifier == 1) {
  9048. # Weather Station (EEP A5-13-01)
  9049. # $db[3] is the dawn sensor where 0x00 = 0 lx ... 0xFF = 999 lx
  9050. # $db[2] is the temperature where 0x00 = -40 °C ... 0xFF = 80 °C
  9051. # $db[1] is the wind speed where 0x00 = 0 m/s ... 0xFF = 70 m/s
  9052. # $db[0]_bit_2 is day / night where 0 = day, 1 = night
  9053. # $db[0]_bit_1 is rain indication where 0 = no (no rain), 1 = yes (rain)
  9054. my $dawn = sprintf "%d", $db[3] * 999 / 255;
  9055. my $temp = sprintf "%0.1f", -40 + $db[2] * 120 / 255;
  9056. my $windSpeed = sprintf "%0.1f", $db[1] * 70 / 255;
  9057. my $dayNight = $db[0] & 4 ? "night" : "day";
  9058. my $isRaining = $db[0] & 2 ? "yes" : "no";
  9059. push @event, "3:brightness:$dawn";
  9060. push @event, "3:dayNight:$dayNight";
  9061. push @event, "3:isRaining:$isRaining";
  9062. push @event, "3:temperature:$temp";
  9063. push @event, "3:windSpeed:$windSpeed";
  9064. push @event, "3:state:T: $temp B: $dawn W: $windSpeed IR: $isRaining";
  9065. } elsif ($identifier == 2) {
  9066. # Sun Intensity (EEP A5-13-02)
  9067. # $db[3] is the sun exposure west where 0x00 = 1 lx ... 0xFF = 150 klx
  9068. # $db[2] is the sun exposure south where 0x00 = 1 lx ... 0xFF = 150 klx
  9069. # $db[1] is the sun exposure east where 0x00 = 1 lx ... 0xFF = 150 klx
  9070. # $db[0]_bit_2 is hemisphere where 0 = north, 1 = south
  9071. push @event, "3:hemisphere:" . ($db[0] & 4 ? "south" : "north");
  9072. push @event, "3:sunWest:" . sprintf "%d", 1 + $db[3] * 149999 / 255;
  9073. push @event, "3:sunSouth:" . sprintf "%d", 1 + $db[2] * 149999 / 255;
  9074. push @event, "3:sunEast:" . sprintf "%d", 1 + $db[1] * 149999 / 255;
  9075. } elsif ($identifier == 3) {
  9076. # Date exchange (EEP A5-13-03)
  9077. push @event, "3:date:" . ($db[1] + 2000) . '-' . $db[2] . '-' . $db[3];
  9078. } elsif ($identifier == 4) {
  9079. # Time und Day exchange (EEP A5-13-04)
  9080. my @day = ('', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
  9081. my $day = ($db[3] & 0xF0) >> 4;
  9082. push @event, "3:weekday:" . $day[$day];
  9083. if ($db[0] & 4) {
  9084. # 12 h time format
  9085. push @event, "3:time:" . ($db[3] & 0x0F) . ':' . $db[2] . ':' . $db[1] . ' ' . ($db[1] & 2 ? 'PM' : 'AM');
  9086. } else {
  9087. push @event, "3:time:" . ($db[3] & 0x0F) . ':' . $db[2] . ':' . $db[1];
  9088. }
  9089. push @event, "3:timeSource:" . ($db[0] & 1 ? 'GPS' : 'RTC');
  9090. } elsif ($identifier == 5) {
  9091. # Direction exchange (EEP A5-13-05)
  9092. push @event, "3:elevation:" . ($db[3] - 90);
  9093. push @event, "3:azimuth:" . hex(substr($data, 2, 4));
  9094. } elsif ($identifier == 6) {
  9095. # Geographic Position exchange (EEP A5-13-06)
  9096. push @event, "3:latitude:" . sprintf("%0.3f", hex(substr($data, 0, 1) . substr($data, 2, 2)) / 22.75 - 90);
  9097. push @event, "3:longitude:" . sprintf("%0.3f", hex(substr($data, 1, 1) . substr($data, 4, 2)) / 13.375 - 180);
  9098. } elsif ($identifier == 7) {
  9099. # Sun Position and Radiation (EEP A5-13-10)
  9100. # $db[3]_bit_7 ... $db[3]_bit_1 is Sun Elevation where 0 = 0 ° ... 90 = 90 °
  9101. # $db[3]_bit_0 is day / night where 0 = day, 1 = night
  9102. # $db[2] is Sun Azimuth where 0 = -90 ° ... 180 = 90 °
  9103. # $db[1] and $db[0]_bit_2 ... $db[0]_bit_0 is Solar Radiation where
  9104. # 0 = 0 W/m2 ... 2000 = 2000 W/m2
  9105. my $sunElev = $db[3] >> 1;
  9106. my $sunAzim = $db[2] - 90;
  9107. my $solarRad = $db[1] << 3 | $db[0] & 7;
  9108. push @event, "3:dayNight:" . ($db[3] & 1 ? "night" : "day");
  9109. push @event, "3:solarRadiation:$solarRad";
  9110. push @event, "3:sunAzimuth:$sunAzim";
  9111. push @event, "3:sunElevation:$sunElev";
  9112. push @event, "3:state:SRA: $solarRad SNA: $sunAzim SNE: $sunElev";
  9113. } else {
  9114. # EEP A5-13-03 ... EEP A5-13-06 not implemented
  9115. }
  9116. } elsif ($st eq "windSensor.01") {
  9117. # Wind Sensor (EEP A5-13-07)
  9118. my @windDirection = ('NNE', 'NE', 'ENE', 'E', 'ESE', 'SE', 'SSE', 'S', 'SSW', 'SW', 'WSW', 'W', 'WNW', 'NW', 'NNW', 'N');
  9119. push @event, "3:battery:" . ($db[0] & 1 ? 'low' : 'ok');
  9120. push @event, "3:windDirection:" . $windDirection[$db[3]];
  9121. push @event, "3:windSpeedAverage:" . $db[2] / 1.275;
  9122. push @event, "3:windSpeedMax:" . $db[1] / 1.275;
  9123. push @event, "3:state:" . $db[2] / 1.275;
  9124. } elsif ($st eq "rainSensor.01") {
  9125. # Rain Sensor (EEP A5-13-08)
  9126. my $ras = ($db[3] & 0x40) >> 6;
  9127. my $rfa = ($db[3] & 0x3F) / 10;
  9128. my $rfc = hex(substr($data, 2, 4));
  9129. my $rain = $rfc * 0.6875 * (1 + $ras * $rfa / 100);
  9130. push @event, "3:battery:" . ($db[0] & 1 ? 'low' : 'ok');
  9131. push @event, "3:rain:$rain";
  9132. push @event, "3:state:$rain";
  9133. } elsif ($st eq "multiFuncSensor") {
  9134. # Multi-Func Sensor (EEP A5-14-01 ... A5-14-06)
  9135. # $db[3] is the voltage where 0x00 = 0 V ... 0xFA = 5.0 V
  9136. # $db[3] > 0xFA is error code
  9137. # $db[2] is the illuminance where min 0x00 = 0 lx, max 0xFA = 1000 lx
  9138. # $db[0]_bit_1 is Vibration where 0 = off, 1 = on
  9139. # $db[0]_bit_0 is Contact where 0 = closed, 1 = open
  9140. my $lux = $db[2] << 2;
  9141. if ($db[2] == 251) {$lux = "over range";}
  9142. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  9143. if ($db[3] > 250) {push @event, "3:errorCode:$db[3]";}
  9144. my $vibration = $db[0] & 2 ? "on" : "off";
  9145. my $contact = $db[0] & 1 ? "open" : "closed";
  9146. push @event, "3:brightness:$lux";
  9147. push @event, "3:contact:$contact";
  9148. push @event, "3:vibration:$vibration";
  9149. push @event, "3:voltage:$voltage";
  9150. push @event, "3:state:C: $contact V: $vibration E: $lux U: $voltage";
  9151. } elsif ($st eq "doorContact") {
  9152. # dual door contact (EEP A5-14-07, A5-14-08)
  9153. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} ne $data) {
  9154. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  9155. my $doorContact = $db[0] & 4 ? 'open' : 'closed';
  9156. my $lockContact = $db[0] & 2 ? 'unlocked' : 'locked';
  9157. my $vibration = $db[0] & 1 ? 'on' : 'off';
  9158. push @event, "3:voltage:$voltage";
  9159. push @event, "3:contact:$doorContact";
  9160. push @event, "3:block:$lockContact";
  9161. push @event, "3:vibration:$vibration";
  9162. push @event, "3:state:C: $doorContact B: $lockContact V: $vibration U: $voltage";
  9163. $hash->{helper}{lastEvent} = $data;
  9164. }
  9165. CommandDeleteReading(undef, "$name alarm");
  9166. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  9167. RemoveInternalTimer($hash->{helper}{alarmTimer});
  9168. InternalTimer(gettimeofday() + 66, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  9169. } elsif ($st eq "windowContact") {
  9170. # window contact (EEP A5-14-09, A5-14-0A)
  9171. if (!exists($hash->{helper}{lastEvent}) || $hash->{helper}{lastEvent} ne $data) {
  9172. my $voltage = sprintf "%0.1f", $db[3] * 0.02;
  9173. my %window = (0 => 'closed', 1 => 'tilt', 2 => 'reserved', 3 => 'open');
  9174. my $window = $window{(($db[0] & 6) >> 1)};
  9175. my $vibration = $db[0] & 1 ? 'on' : 'off';
  9176. push @event, "3:voltage:$voltage";
  9177. push @event, "3:window:$window";
  9178. push @event, "3:vibration:$vibration";
  9179. push @event, "3:state:W: $window V: $vibration U: $voltage";
  9180. $hash->{helper}{lastEvent} = $data;
  9181. }
  9182. CommandDeleteReading(undef, "$name alarm");
  9183. @{$hash->{helper}{alarmTimer}} = ($hash, 'alarm', 'dead_sensor', 1, 5);
  9184. RemoveInternalTimer($hash->{helper}{alarmTimer});
  9185. InternalTimer(gettimeofday() + 66, 'EnOcean_readingsSingleUpdate', $hash->{helper}{alarmTimer}, 0);
  9186. } elsif ($st =~ m/^digitalInput\.0[12]$/) {
  9187. # Digital Input (EEP A5-30-01, A5-30-02)
  9188. my $contact;
  9189. if ($st eq "digitalInput.01") {
  9190. # Single Input Contact, Batterie Monitor (EEP A5-30-01)
  9191. # [Thermokon SR65 DI, untested]
  9192. # $db[2] is the supply voltage, if >= 121 = battery ok
  9193. # $db[1] is the input state, if <= 195 = contact closed
  9194. my $battery = $db[2] >= 121 ? "ok" : "low";
  9195. $contact = $db[1] <= 195 ? "closed" : "open";
  9196. push @event, "3:battery:$battery";
  9197. } else {
  9198. # Single Input Contact (EEP A5-30-02)
  9199. # $db[0]_bit_0 is the input state where 0 = closed, 1 = open
  9200. $contact = $db[0] & 1 ? "open" : "closed";
  9201. }
  9202. push @event, "3:contact:$contact";
  9203. push @event, "3:state:$contact";
  9204. } elsif ($st eq "digitalInput.03") {
  9205. # 4 digital inputs, wake, temperature (EEP A5-30-03)
  9206. my $in0 = $db[1] & 1;
  9207. my $in1 = ($db[1] & 2) > 1;
  9208. my $in2 = ($db[1] & 4) > 2;
  9209. my $in3 = ($db[1] & 8) > 3;
  9210. my $wake = $db[1] & 16 ? 'high' : 'low';
  9211. my $temperature = sprintf "%0.1f", 40 - $db[2] * 40 / 255;
  9212. push @event, "3:in0:$in0";
  9213. push @event, "3:in1:$in1";
  9214. push @event, "3:in2:$in2";
  9215. push @event, "3:in3:$in3";
  9216. push @event, "3:wake:$wake";
  9217. push @event, "3:temperature:$temperature";
  9218. push @event, "3:state:T: $temperature I: " . $in0 . $in1 . $in2 . $in3 . " W: " . $wake;
  9219. } elsif ($st eq "digitalInput.04") {
  9220. # 3 digital inputs, 1 digital input 8 bit (EEP A5-30-04)
  9221. my $in0 = $db[0] & 1;
  9222. my $in1 = ($db[0] & 2) > 1;
  9223. my $in2 = ($db[0] & 4) > 2;
  9224. my $in3 = $db[1];
  9225. push @event, "3:in0:$in0";
  9226. push @event, "3:in1:$in1";
  9227. push @event, "3:in2:$in2";
  9228. push @event, "3:in3:$in3";
  9229. push @event, "3:state:" . $in0 . $in1 . $in2 . " " . $in3;
  9230. } elsif ($st eq "digitalInput.05") {
  9231. # single input contact, retransmission, battery monitor (EEP A5-30-05)
  9232. my $signalIdx = $db[1] & 0x7F;
  9233. my $signalIdxLast = ReadingsVal($name, "signalIdx", undef);
  9234. my $signalType = $db[1] & 0x80 ? "heartbeat" : "event";
  9235. push @event, "3:voltage:" . sprintf "%0.1f", $db[2] / 255 * 3.3;
  9236. push @event, "3:signalIdx:$signalIdx";
  9237. push @event, "3:telegramType:$signalType";
  9238. if (defined $signalIdxLast) {
  9239. if ($signalIdx == $signalIdxLast + 1 || $signalIdx == 0 && $signalIdxLast == 127) {
  9240. push @event, "3:state:$signalType";
  9241. } else {
  9242. push @event, "3:state:error";
  9243. }
  9244. } else {
  9245. push @event, "3:state:$signalType";
  9246. }
  9247. } elsif ($st eq "gateway") {
  9248. # Gateway (EEP A5-38-08)
  9249. # $db[3] is the command ID ($gwCmdID)
  9250. # Eltako devices not send teach-in telegrams
  9251. if(($db[0] & 8) == 0) {
  9252. # teach-in, identify and store command type in attr gwCmd
  9253. my $gwCmd = AttrVal($name, "gwCmd", undef);
  9254. if (!$gwCmd) {
  9255. $gwCmd = $EnO_gwCmd[$db[3] - 1];
  9256. $attr{$name}{gwCmd} = $gwCmd;
  9257. }
  9258. }
  9259. if ($db[3] == 1) {
  9260. # Switching
  9261. # Eltako devices not send A5 telegrams
  9262. push @event, "3:executeTime:" . sprintf "%0.1f", (($db[2] << 8) | $db[1]) / 10;
  9263. push @event, "3:block:" . ($db[0] & 4 ? "lock" : "unlock");
  9264. push @event, "3:executeType" . ($db[0] & 2 ? "delay" : "duration");
  9265. push @event, "3:state:" . ($db[0] & 1 ? "on" : "off");
  9266. } elsif ($db[3] == 2) {
  9267. # Dimming
  9268. # $db[0]_bit_2 is store final value, not used, because
  9269. # dimming value is always stored
  9270. push @event, "3:rampTime:$db[1]";
  9271. push @event, "3:state:" . ($db[0] & 0x01 ? "on" : "off");
  9272. if ($db[0] & 4) {
  9273. # Relative Dimming Range
  9274. push @event, "3:dim:" . sprintf "%d", $db[2] * 100 / 255;
  9275. } else {
  9276. push @event, "3:dim:$db[2]";
  9277. }
  9278. push @event, "3:dimValueLast:$db[2]" if ($db[2] > 0);
  9279. } elsif ($db[3] == 3) {
  9280. # Setpoint shift
  9281. # $db1 is setpoint shift where 0 = -12.7 K ... 255 = 12.8 K
  9282. my $setpointShift = sprintf "%0.1f", -12.7 + $db[1] / 10;
  9283. push @event, "3:setpointShift:$setpointShift";
  9284. push @event, "3:state:$setpointShift";
  9285. } elsif ($db[3] == 4) {
  9286. # Basic Setpoint
  9287. # $db1 is setpoint where 0 = 0 °C ... 255 = 51.2 °C
  9288. my $setpoint = sprintf "%0.1f", $db[1] / 5;
  9289. push @event, "3:setpoint:$setpoint";
  9290. push @event, "3:state:$setpoint";
  9291. } elsif ($db[3] == 5) {
  9292. # Control variable
  9293. # $db1 is control variable override where 0 = 0 % ... 255 = 100 %
  9294. push @event, "3:controlVar:" . sprintf "%d", $db[1] * 100 / 255;
  9295. my $controllerMode = ($db[0] & 0x60) >> 5;
  9296. if ($controllerMode == 0) {
  9297. push @event, "3:controllerMode:auto";
  9298. push @event, "3:state:auto";
  9299. } elsif ($controllerMode == 1) {
  9300. push @event, "3:controllerMode:heating";
  9301. push @event, "3:state:heating";
  9302. } elsif ($controllerMode == 2){
  9303. push @event, "3:controllerMode:cooling";
  9304. push @event, "3:state:cooling";
  9305. } elsif ($controllerMode == 3){
  9306. push @event, "3:controllerMode:off";
  9307. push @event, "3:state:off";
  9308. }
  9309. push @event, "3:controllerState:" . ($db[0] & 0x10 ? "override" : "auto");
  9310. push @event, "3:energyHoldOff:" . ($db[0] & 4 ? "holdoff" : "normal");
  9311. my $occupancy = $db[0] & 3;
  9312. if ($occupancy == 0) {
  9313. push @event, "3:presence:present";
  9314. } elsif ($occupancy == 1){
  9315. push @event, "3:presence:absent";
  9316. } elsif ($occupancy == 2){
  9317. push @event, "3:presence:standby";
  9318. }
  9319. } elsif ($db[3] == 6) {
  9320. # Fan stage
  9321. if ($db[1] == 0) {
  9322. push @event, "3:fan:0";
  9323. push @event, "3:state:0";
  9324. } elsif ($db[1] == 1) {
  9325. push @event, "3:fan:1";
  9326. push @event, "3:state:1";
  9327. } elsif ($db[1] == 2) {
  9328. push @event, "3:fan:2";
  9329. push @event, "3:state:2";
  9330. } elsif ($db[1] == 3) {
  9331. push @event, "3:fan:3";
  9332. push @event, "3:state:3";
  9333. } elsif ($db[1] == 255) {
  9334. push @event, "3:fan:auto";
  9335. push @event, "3:state:auto";
  9336. }
  9337. } else {
  9338. push @event, "3:state:Gateway Command ID $db[3] unknown.";
  9339. }
  9340. } elsif ($st eq "energyManagement.01") {
  9341. # Energy Management, Demand Response
  9342. # (A5-37-01)
  9343. EnOcean_energyManagement_01Parse($hash, @db);
  9344. } elsif ($st eq "manufProfile") {
  9345. # Manufacturer Specific Applications (EEP A5-3F-7F)
  9346. if ($manufID eq "002") {
  9347. # [Thermokon SR65 3AI, untested]
  9348. # $db[3] is the input 3 where 0x00 = 0 V ... 0xFF = 10 V
  9349. # $db[2] is the input 2 where 0x00 = 0 V ... 0xFF = 10 V
  9350. # $db[1] is the input 1 where 0x00 = 0 V ... 0xFF = 10 V
  9351. my $input3 = sprintf "%0.2f", $db[3] * 10 / 255;
  9352. my $input2 = sprintf "%0.2f", $db[2] * 10 / 255;
  9353. my $input1 = sprintf "%0.2f", $db[1] * 10 / 255;
  9354. push @event, "3:input1:$input1";
  9355. push @event, "3:input2:$input2";
  9356. push @event, "3:input3:$input3";
  9357. push @event, "3:state:I1: $input1 I2: $input2 I3: $input3";
  9358. } elsif ($manufID eq "005") {
  9359. # omnio
  9360. if ($db[0] == 0x0C) {
  9361. # omnio UPH 2330/1x
  9362. my $channel = ($db[1] & 0xF0) > 4;
  9363. my $emergencyMode = $db[1] & 8 ? "on" : "off";
  9364. my $window = $db[1] & 4 ? "open" : "closed";
  9365. my $nightReduction = $db[1] & 2 ? "on" : "off";
  9366. my $state = $db[1] & 1 ? "on" : "off";
  9367. my $temperature = sprintf "%0.1f", $db[2] * 40 / 250;
  9368. my $setpointTemp = sprintf "%0.1f", $db[3] * 40 / 250;
  9369. push @event, "3:emergencyMode" . $channel . ":$emergencyMode";
  9370. push @event, "3:window" . $channel . ":$window";
  9371. push @event, "3:nightReduction" . $channel . ":$nightReduction";
  9372. push @event, "3:temperature" . $channel . ":$temperature";
  9373. push @event, "3:setpointTemp" . $channel . ":$setpointTemp";
  9374. push @event, "3:state:$state";
  9375. }
  9376. } elsif ($manufID eq "00D") {
  9377. # [Eltako shutter]
  9378. my $angleMax = AttrVal($name, "angleMax", 90);
  9379. my $angleMin = AttrVal($name, "angleMin", -90);
  9380. my $anglePos = ReadingsVal($name, ".anglePosStart", undef);
  9381. my $angleTime = AttrVal($name, "angleTime", 0);
  9382. my $position = ReadingsVal($name, ".positionStart", undef);
  9383. my $shutTime = AttrVal($name, "shutTime", 255);
  9384. my $shutTimeStop = ($db[3] << 8 | $db[2]) * 0.1;
  9385. my $state;
  9386. $angleMax = 90 if ($angleMax !~ m/^[+-]?\d+$/);
  9387. $angleMax = 180 if ($angleMax > 180);
  9388. $angleMax = -180 if ($angleMax < -180);
  9389. $angleMin = -90 if ($angleMin !~ m/^[+-]?\d+$/);
  9390. $angleMin = 180 if ($angleMin > 180);
  9391. $angleMin = -180 if ($angleMin < -180);
  9392. ($angleMax, $angleMin) = ($angleMin, $angleMax) if ($angleMin > $angleMax);
  9393. $angleMax ++ if ($angleMin == $angleMax);
  9394. $angleTime = 0 if ($angleTime !~ m/^[+-]?\d+$/);
  9395. $angleTime = 6 if ($angleTime > 6);
  9396. $angleTime = 0 if ($angleTime < 0);
  9397. $shutTime = 255 if ($shutTime !~ m/^[+-]?\d+$/);
  9398. $shutTime = 255 if ($shutTime > 255);
  9399. $shutTime = 1 if ($shutTime < 1);
  9400. if ($db[0] == 0x0A) {
  9401. push @event, "3:block:unlock";
  9402. } elsif ($db[0] == 0x0E) {
  9403. push @event, "3:block:lock";
  9404. }
  9405. if (defined $position) {
  9406. if ($db[1] == 1) {
  9407. # up
  9408. $position -= $shutTimeStop / $shutTime * 100;
  9409. if ($angleTime) {
  9410. $anglePos -= ($angleMax - $angleMin) * $shutTimeStop / $angleTime;
  9411. if ($anglePos < $angleMin) {
  9412. $anglePos = $angleMin;
  9413. }
  9414. } else {
  9415. $anglePos = $angleMin;
  9416. }
  9417. if ($position <= 0) {
  9418. $anglePos = 0;
  9419. $position = 0;
  9420. push @event, "3:endPosition:open";
  9421. $state = "open";
  9422. } else {
  9423. push @event, "3:endPosition:not_reached";
  9424. $state = "stop";
  9425. }
  9426. push @event, "3:anglePos:" . sprintf("%d", $anglePos);
  9427. push @event, "3:position:" . sprintf("%d", $position);
  9428. push @event, "3:.anglePosStart:" . sprintf("%d", $anglePos);
  9429. push @event, "3:.positionStart:" . sprintf("%d", $position);
  9430. } elsif ($db[1] == 2) {
  9431. # down
  9432. $position += $shutTimeStop / $shutTime * 100;
  9433. if ($angleTime) {
  9434. $anglePos += ($angleMax - $angleMin) * $shutTimeStop / $angleTime;
  9435. if ($anglePos > $angleMax) {
  9436. $anglePos = $angleMax;
  9437. }
  9438. } else {
  9439. $anglePos = $angleMax;
  9440. }
  9441. if($position > 100) {
  9442. $anglePos = $angleMax;
  9443. $position = 100;
  9444. push @event, "3:endPosition:closed";
  9445. $state = "closed";
  9446. } else {
  9447. push @event, "3:endPosition:not_reached";
  9448. $state = "stop";
  9449. }
  9450. push @event, "3:anglePos:" . sprintf("%d", $anglePos);
  9451. push @event, "3:position:" . sprintf("%d", $position);
  9452. push @event, "3:.anglePosStart:" . sprintf("%d", $anglePos);
  9453. push @event, "3:.positionStart:" . sprintf("%d", $position);
  9454. } else {
  9455. $state = "not_reached";
  9456. }
  9457. push @event, "3:state:$state";
  9458. }
  9459. } else {
  9460. # Unknown Application
  9461. push @event, "3:state:Manufacturer Specific Application unknown";
  9462. }
  9463. } elsif ($st eq "PM101") {
  9464. # Light and Presence Sensor [Omnio Ratio eagle-PM101]
  9465. # The sensor also sends switching commands (RORG F6) with the senderID-1
  9466. # $db[2] is the illuminance where 0x00 = 0 lx ... 0xFF = 1000 lx
  9467. my $channel2 = $db[0] & 2 ? "on" : "off";
  9468. push @event, "3:brightness:" . ($db[2] << 2);
  9469. push @event, "3:channel1:" . ($db[0] & 1 ? "on" : "off");
  9470. push @event, "3:channel2:" . $channel2;
  9471. push @event, "3:motion:" . $channel2;
  9472. push @event, "3:state:" . $channel2;
  9473. } elsif ($st eq "radioLinkTest") {
  9474. # Radio Link Test (EEP A5-3F-00)
  9475. @{$hash->{helper}{rlt}{param}} = ('parse', $hash, $data, $subDef, 'master', $RSSI);
  9476. EnOcean_RLT($hash->{helper}{rlt}{param});
  9477. } elsif ($st eq "raw") {
  9478. # raw
  9479. push @event, "3:state:RORG: $rorg DATA: $data STATUS: $status ODATA: $odata";
  9480. } else {
  9481. # unknown devices
  9482. push @event, "3:state:$db[3]";
  9483. push @event, "3:sensor1:$db[3]";
  9484. push @event, "3:sensor2:$db[2]";
  9485. push @event, "3:sensor3:$db[1]";
  9486. push @event, "3:D3:" . ($db[0] & 8 ? 1 : 0);
  9487. push @event, "3:D2:" . ($db[0] & 4 ? 1 : 0);
  9488. push @event, "3:D1:" . ($db[0] & 2 ? 1 : 0);
  9489. push @event, "3:D0:" . ($db[0] & 1 ? 1 : 0);
  9490. }
  9491. } elsif ($rorg eq "D2") {
  9492. # VLD telegram
  9493. if ($st eq "roomCtrlPanel.00") {
  9494. # EEP D2-10-01 - D2-10-03
  9495. my ($key, $val);
  9496. # message identifier
  9497. my $mid = hex(substr($data, 0, 2)) >> 5;
  9498. # message continuation flag
  9499. my $mcf = hex(substr($data, 0, 2)) & 3;
  9500. my ($irc, $fbc, $gmt);
  9501. if ($mcf == 0) {
  9502. # message complete
  9503. # read stored telegrams
  9504. if (!defined($hash->{helper}{$mid}{messagePart})) {
  9505. $hash->{helper}{$mid}{messagePart} = 1;
  9506. $hash->{helper}{$mid}{data}{1} = $data;
  9507. } else {
  9508. $hash->{helper}{$mid}{messagePart} += 1;
  9509. $hash->{helper}{$mid}{data}{$hash->{helper}{$mid}{messagePart}} = $data;
  9510. }
  9511. if ($mid == 4) {
  9512. CommandDeleteAttr(undef, "$name timeProgram1");
  9513. CommandDeleteAttr(undef, "$name timeProgram2");
  9514. CommandDeleteAttr(undef, "$name timeProgram3");
  9515. CommandDeleteAttr(undef, "$name timeProgram4");
  9516. }
  9517. for (my $partCntr = $hash->{helper}{$mid}{messagePart}; $partCntr > 0; $partCntr --) {
  9518. $data = $hash->{helper}{$mid}{data}{$partCntr};
  9519. delete $hash->{helper}{$mid}{data}{$partCntr};
  9520. if ($partCntr == 1) {
  9521. delete $hash->{helper}{$mid}{messagePart};
  9522. } else {
  9523. $hash->{helper}{$mid}{messagePart} --;
  9524. }
  9525. $dbCntr = 0;
  9526. for (my $strCntr = length($data) / 2 - 1; $strCntr >= 0; $strCntr --) {
  9527. $db[$dbCntr] = hex substr($data, $strCntr * 2, 2);
  9528. $dbCntr++;
  9529. }
  9530. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write MID $mid DATA $data to part $partCntr";
  9531. #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];
  9532. if ($mid == 0) {
  9533. # general message
  9534. $irc = ($db[0] & 56) >> 3;
  9535. $fbc = ($db[0] & 6) >> 1;
  9536. $gmt = $db[0] & 1;
  9537. #push @event, "3:general:$data";
  9538. } elsif ($mid == 1) {
  9539. # data message
  9540. my $temperature = "-";
  9541. $temperature = sprintf "%.1f", $db[0] / 254 * 40 if ($db[2] & 1);
  9542. push @event, "3:temperature:$temperature";
  9543. my $setpointTemp = "-";
  9544. $setpointTemp = sprintf "%.1f", $db[1] / 254 * 40 if ($db[2] & 2);
  9545. push @event, "3:setpointTemp:$setpointTemp";
  9546. my $roomCtrlMode = ($db[2] & 12) >> 2;
  9547. if ($roomCtrlMode == 3) {
  9548. $roomCtrlMode = "buildingProtection";
  9549. } elsif ($roomCtrlMode == 2) {
  9550. $roomCtrlMode = "preComfort";
  9551. } elsif ($roomCtrlMode == 1) {
  9552. $roomCtrlMode = "economy";
  9553. } else{
  9554. $roomCtrlMode = "comfort";
  9555. }
  9556. push @event, "3:roomCtrlMode:$roomCtrlMode";
  9557. my $heating = ($db[2] & 48) >> 4;
  9558. if ($heating == 3) {
  9559. $heating = "auto";
  9560. } elsif ($heating == 2) {
  9561. $heating = "off";
  9562. } elsif ($heating == 1) {
  9563. $heating = "on";
  9564. } else{
  9565. $heating = "-";
  9566. }
  9567. if ($heating ne "-") {
  9568. push @event, "3:heating:$heating";
  9569. }
  9570. my $cooling = ($db[2] & 192) >> 6;
  9571. if ($cooling == 3) {
  9572. $cooling = "auto";
  9573. } elsif ($cooling == 2) {
  9574. $cooling = "off";
  9575. } elsif ($cooling == 1) {
  9576. $cooling = "on";
  9577. } else{
  9578. $cooling = "-";
  9579. }
  9580. if ($cooling ne "-") {
  9581. push @event, "3:cooling:$cooling";
  9582. }
  9583. my $occupancy = $db[3] & 3;
  9584. if ($occupancy == 3) {
  9585. $occupancy = "reserved";
  9586. } elsif ($occupancy == 2) {
  9587. $occupancy = "absent";
  9588. } elsif ($occupancy == 1) {
  9589. $occupancy = "present";
  9590. } else{
  9591. $occupancy = "-";
  9592. }
  9593. if ($occupancy eq "-") {
  9594. $occupancy = ReadingsVal($name, "occupancy", "-");
  9595. } else {
  9596. push @event, "3:occupancy:$occupancy";
  9597. }
  9598. my $motion = ($db[3] & 12) >> 2;
  9599. if ($motion == 3) {
  9600. $motion = "reserved";
  9601. } elsif ($motion == 2) {
  9602. $motion = "on";
  9603. } elsif ($motion == 1) {
  9604. $motion = "off";
  9605. } else{
  9606. $motion = "-";
  9607. }
  9608. if ($motion eq "-") {
  9609. $motion = ReadingsVal($name, "motion", "-");
  9610. } else {
  9611. push @event, "3:motion:$motion";
  9612. }
  9613. push @event, "3:solarPowered:" . ($db[3] & 16 ? "no" : "yes");
  9614. my $battery = ($db[3] & 96) >> 5;
  9615. if ($battery == 3) {
  9616. $battery = "empty";
  9617. } elsif ($battery == 2) {
  9618. $battery = "low";
  9619. } elsif ($battery == 1) {
  9620. $battery = "ok";
  9621. } else{
  9622. $battery = "-";
  9623. }
  9624. if ($battery ne "-") {
  9625. push @event, "3:battery:$battery";
  9626. }
  9627. my $window = $db[4] & 3;
  9628. if ($window == 3) {
  9629. $window = "reserved";
  9630. } elsif ($window == 2) {
  9631. $window = "open";
  9632. } elsif ($window == 1) {
  9633. $window = "closed";
  9634. } else{
  9635. $window = "-";
  9636. }
  9637. if ($window ne "-") {
  9638. push @event, "3:window:$window";
  9639. }
  9640. push @event, "3:moldWarning:" . ($db[4] & 4 ? "on" : "off");
  9641. push @event, "3:customWarning1:" . ($db[4] & 8 ? "on" : "off");
  9642. push @event, "3:customWarning2:" . ($db[4] & 16 ? "on" : "off");
  9643. push @event, "3:fanSpeedMode:" . ($db[4] & 64 ? "local" : "central");
  9644. my $fanSpeed = 0;
  9645. $fanSpeed = sprintf "%d", $db[5] & 127 if ($db[4] & 128);
  9646. push @event, "3:fanSpeed:$fanSpeed";
  9647. my $humi = "-";
  9648. $humi = sprintf "%d", $db[6] / 2.55 if ($db[5] & 128);
  9649. push @event, "3:humidity:$humi";
  9650. push @event, "3:state:T: $temperature H: $humi F: $fanSpeed SPT: $setpointTemp O: $occupancy M: $motion";
  9651. } elsif ($mid == 2) {
  9652. # configuration message
  9653. $attr{$name}{blockFanSpeed} = $db[6] & 1 ? "no" : "yes";
  9654. $attr{$name}{blockSetpointTemp} = $db[6] & 2 ? "no" : "yes";
  9655. $attr{$name}{blockOccupancy} = $db[6] & 4 ? "no" : "yes";
  9656. $attr{$name}{blockTimeProgram} = $db[6] & 8 ? "no" : "yes";
  9657. $attr{$name}{blockDateTime} = $db[6] & 16 ? "no" : "yes";
  9658. $attr{$name}{blockDisplay} = $db[6] & 32 ? "no" : "yes";
  9659. $attr{$name}{blockTemp} = $db[6] & 64 ? "no" : "yes";
  9660. $attr{$name}{blockMotion} = $db[6] & 128 ? "no" : "yes";
  9661. my $pollInterval = $db[5] >> 2;
  9662. if ($pollInterval == 63) {
  9663. $attr{$name}{pollInterval} = 1440;
  9664. } elsif ($pollInterval == 62) {
  9665. $attr{$name}{pollInterval} = 720;
  9666. } elsif ($pollInterval == 61) {
  9667. $attr{$name}{pollInterval} = 180;
  9668. } else {
  9669. $attr{$name}{pollInterval} = $pollInterval;
  9670. }
  9671. $attr{$name}{blockKey} = $db[5] & 2 ? "no" : "yes";
  9672. my $displayContent = $db[4] >> 5;
  9673. my %displayContent = (7 => "humidity",
  9674. 6 => "off",
  9675. 5 => "setpointTemp",
  9676. 4 => "tempertureExtern",
  9677. 3 => "temperatureIntern",
  9678. 2 => "time",
  9679. 1 => "default",
  9680. 0 => "no_change"
  9681. );
  9682. while (($key, $val) = each(%displayContent)) {
  9683. $attr{$name}{displayContent} = $val if ($key == $displayContent);
  9684. }
  9685. my $temperatureScale = ($db[4] & 24) >> 3;
  9686. my %temperatureScale = (3 => "F",
  9687. 2 => "C",
  9688. 1 => "default",
  9689. 0 => "no_change"
  9690. );
  9691. while (($key, $val) = each(%temperatureScale)) {
  9692. $attr{$name}{temperatureScale} = $val if ($key == $temperatureScale);
  9693. }
  9694. $attr{$name}{daylightSavingTime} = $db[4] & 4 ? "not_supported" : "supported";
  9695. my $timeNotation = $db[4] & 3;
  9696. if ($timeNotation == 0) {
  9697. $attr{$name}{timeNotation} = "no_change";
  9698. } elsif ($timeNotation == 1) {
  9699. $attr{$name}{timeNotation} = "default";
  9700. } elsif ($timeNotation == 2) {
  9701. $attr{$name}{timeNotation} = 24;
  9702. } elsif ($timeNotation == 3) {
  9703. $attr{$name}{timeNotation} = 12;
  9704. }
  9705. EnOcean_CommandSave(undef, undef);
  9706. } elsif ($mid == 3) {
  9707. # room control setup
  9708. my $setpointComfort = "-";
  9709. $setpointComfort = sprintf "%.1f", $db[1] / 254 * 40 if ($db[0] & 1);
  9710. push @event, "3:setpointComfortTemp:$setpointComfort";
  9711. my $setpointEconomy = "-";
  9712. $setpointEconomy = sprintf "%.1f", $db[2] / 254 * 40 if ($db[0] & 2);
  9713. push @event, "3:setpointEconomyTemp:$setpointEconomy";
  9714. my $setpointPreComfort = "-";
  9715. $setpointPreComfort = sprintf "%.1f", $db[3] / 254 * 40 if ($db[0] & 4);
  9716. push @event, "3:setpointPreComfortTemp:$setpointPreComfort";
  9717. my $setpointBuildingProtection = "-";
  9718. $setpointBuildingProtection = sprintf "%.1f", $db[3] / 254 * 40 if ($db[0] & 8);
  9719. push @event, "3:setpointBuildingProtectionTemp:$setpointBuildingProtection";
  9720. } elsif ($mid == 4) {
  9721. # time program setup
  9722. my $timeProgram = "timeProgram" . $partCntr;
  9723. my $period = $db[0] >> 4;
  9724. my $periodVal = "";
  9725. my %period = (15 => "FrMo",
  9726. 14 => "FrSu",
  9727. 13 => "ThFr",
  9728. 12 => "WeFr",
  9729. 11 => "TuTh",
  9730. 10 => "MoWe",
  9731. 9 => "Su",
  9732. 8 => "Sa",
  9733. 7 => "Fr",
  9734. 6 => "Th",
  9735. 5 => "We",
  9736. 4 => "Tu",
  9737. 3 => "Mo",
  9738. 2 => "SaSu",
  9739. 1 => "MoFr",
  9740. 0 => "MoSu"
  9741. );
  9742. while (($key, $val) = each(%period)) {
  9743. $periodVal = $val if ($key == $period);
  9744. }
  9745. my $roomCtrlMode = ($db[0] & 12) >> 2;
  9746. if ($roomCtrlMode == 3) {
  9747. $roomCtrlMode = "buildingProtection";
  9748. } elsif ($roomCtrlMode == 2) {
  9749. $roomCtrlMode = "preComfort";
  9750. } elsif ($roomCtrlMode == 1) {
  9751. $roomCtrlMode = "economy";
  9752. } else{
  9753. $roomCtrlMode = "comfort";
  9754. }
  9755. my ($startHour, $startMinute, $endHour, $endMinute) = ($db[1], $db[2], $db[3], $db[4]);
  9756. $startHour = $startHour < 10 ? $startHour = "0" . $startHour : $startHour;
  9757. $startMinute = $startMinute < 10 ? $startMinute = "0" . $startMinute : $startMinute;
  9758. $endHour = $endHour < 10 ? $endHour = "0" . $endHour : $endHour;
  9759. $endMinute = $endMinute < 10 ? $endMinute = "0" . $endMinute : $endMinute;
  9760. #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];
  9761. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write 3 MID $mid DATA $data to $timeProgram VAL: $periodVal $startHour:$startMinute $endHour:$endMinute $roomCtrlMode";
  9762. $attr{$name}{$timeProgram} = "$periodVal $startHour:$startMinute $endHour:$endMinute $roomCtrlMode";
  9763. #Log3 $name, 2, "EnOcean $name EnOcean_Parse write 4 MID $mid DATA $data to $timeProgram VAL: $attr{$name}{$timeProgram}";
  9764. EnOcean_CommandSave(undef, undef);
  9765. }
  9766. }
  9767. ($err, $response) = EnOcean_roomCtrlPanel_00Snd(undef, $hash, $packetType, $mid, $mcf, $irc, $fbc, $gmt);
  9768. } elsif ($mcf == 1) {
  9769. # message incomplete
  9770. if (!defined($hash->{helper}{$mid}{messagePart})) {
  9771. $hash->{helper}{$mid}{messagePart} = 1;
  9772. } elsif ($hash->{helper}{$mid}{messagePart} >= 4) {
  9773. # max 4 message parts stored
  9774. for (my $partCntr = 1; $partCntr < $hash->{helper}{$mid}{messagePart}; $partCntr ++) {
  9775. $hash->{helper}{$mid}{data}{$partCntr} = $hash->{helper}{$mid}{data}{$partCntr + 1};
  9776. }
  9777. } else {
  9778. $hash->{helper}{$mid}{messagePart} += 1;
  9779. }
  9780. $hash->{helper}{$mid}{data}{$hash->{helper}{$mid}{messagePart}} = $data;
  9781. #Log3 $name, 2, "EnOcean $name EnOcean_Parse store MID $mid DATA $data to messagePart $hash->{helper}{$mid}{messagePart}";
  9782. ($err, $response) = EnOcean_roomCtrlPanel_00Snd(undef, $hash, $packetType, $mid, $mcf, undef, undef, undef);
  9783. }
  9784. } elsif ($st eq "actuator.01") {
  9785. # Electronic switches and dimmers with Energy Measurement and Local Control
  9786. # (D2-01-00 - D2-01-12)
  9787. my $channel = (hex substr($data, 2, 2)) & 0x1F;
  9788. if ($channel == 31) {$channel = "Input";}
  9789. my $cmd = hex substr($data, 1, 1);
  9790. if ($cmd == 4) {
  9791. # actuator status response
  9792. my $overCurrentOff;
  9793. my $error;
  9794. my $localControl;
  9795. my $dim;
  9796. push @event, "3:powerFailure" . $channel . ":" . ($db[2] & 0x80 ? "enabled" : "disabled");
  9797. push @event, "3:powerFailureDetection" . $channel . ":" . ($db[2] & 0x40 ? "detected" : "not_detected");
  9798. if (($db[1] & 0x80) == 0) {
  9799. $overCurrentOff = "ready";
  9800. } else {
  9801. $overCurrentOff = "executed";
  9802. }
  9803. push @event, "3:overCurrentOff" . $channel . ":" . $overCurrentOff;
  9804. if ((($db[1] & 0x60) >> 5) == 1) {
  9805. $error = "warning";
  9806. } elsif ((($db[1] & 0x60) >> 5) == 2) {
  9807. $error = "failure";
  9808. } elsif ((($db[1] & 0x60) >> 5) == 3) {
  9809. $error = "not_supported";
  9810. } else {
  9811. $error = "ok";
  9812. }
  9813. push @event, "3:error" . $channel . ":" . $error;
  9814. if (($db[0] & 0x80) == 0) {
  9815. $localControl = "disabled";
  9816. } else {
  9817. $localControl = "enabled";
  9818. }
  9819. push @event, "3:localControl" . $channel . ":" . $localControl;
  9820. my $dimValue = $db[0] & 0x7F;
  9821. if ($dimValue == 0) {
  9822. push @event, "3:channel" . $channel . ":off";
  9823. push @event, "3:state:off";
  9824. } else {
  9825. push @event, "3:channel" . $channel . ":on";
  9826. push @event, "3:state:on";
  9827. }
  9828. if ($channel ne "Input") {
  9829. push @event, "3:dim:" . $dimValue;
  9830. push @event, "3:dim" . $channel . ":" . $dimValue;
  9831. } else {
  9832. push @event, "3:dim" . $channel . ":" . $dimValue;
  9833. }
  9834. } elsif ($cmd == 7) {
  9835. # actuator measurement response
  9836. my $unit = $db[4] >> 5;
  9837. if ($unit == 1) {
  9838. #$unit = "Wh";
  9839. $unit = "KWh";
  9840. push @event, "3:energyUnit" . $channel . ":" . $unit;
  9841. push @event, "3:energy" . $channel . ":" . sprintf("%.3f", (hex substr($data, 4, 8)) / 1000);
  9842. } elsif ($unit == 2) {
  9843. $unit = "KWh";
  9844. push @event, "3:energyUnit" . $channel . ":" . $unit;
  9845. push @event, "3:energy" . $channel . ":" . hex substr($data, 4, 8);
  9846. } elsif ($unit == 3) {
  9847. $unit = "W";
  9848. push @event, "3:powerUnit" . $channel . ":" . $unit;
  9849. push @event, "3:power" . $channel . ":" . hex substr($data, 4, 8);
  9850. } elsif ($unit == 4) {
  9851. $unit = "KW";
  9852. push @event, "3:powerUnit" . $channel . ":" . $unit;
  9853. push @event, "3:power" . $channel . ":" . hex substr($data, 4, 8);
  9854. } else {
  9855. $unit = "Ws";
  9856. push @event, "3:energyUnit" . $channel . ":" . $unit;
  9857. push @event, "3:energy" . $channel . ":" . hex substr($data, 4, 8);
  9858. }
  9859. } elsif ($cmd == 10) {
  9860. # pilot wire mode response
  9861. my $roomCtrlMode = $db[0] & 3;
  9862. my %roomCtrlMode = (
  9863. 0 => "off",
  9864. 1 => "comfort",
  9865. 2 => "economy",
  9866. 3 => "buildingProtection",
  9867. 4 => "comfort-1",
  9868. 5 => "comfort-2"
  9869. );
  9870. push @event, "3:roomCtrlMode" . $roomCtrlMode{$roomCtrlMode} if (exists $roomCtrlMode{$roomCtrlMode});
  9871. } elsif ($cmd == 13) {
  9872. # external interface settings
  9873. push @event, "3:autoOffTime" . $channel . ":" . sprintf("%0.1f", hex(substr($data, 4, 4)) * 0.1);
  9874. push @event, "3:delayOffTime" . $channel . ":" . sprintf("%0.1f", hex(substr($data, 8, 4)) * 0.1);
  9875. my $extSwitchMode = ($db[0] & 0xC0) >> 6;
  9876. my %extSwitchMode = (
  9877. 0 => "unavailable",
  9878. 1 => "switch",
  9879. 2 => "pushbutton",
  9880. 3 => "auto"
  9881. );
  9882. push @event, "3:extSwitchMode" . $extSwitchMode{$extSwitchMode} if (exists $extSwitchMode{$extSwitchMode});
  9883. push @event, "3:extSwitchType" . ($db[0] & 0x20 ? 'direction' : 'toggle');
  9884. } else {
  9885. # unknown response
  9886. }
  9887. } elsif ($st eq "switch.00" || $st eq "windowHandle.10") {
  9888. if ($db[0] == 1) {
  9889. push @event, "3:state:open_from_tilted";
  9890. } elsif ($db[0] == 2) {
  9891. push @event, "3:state:closed";
  9892. } elsif ($db[0] == 3) {
  9893. push @event, "3:state:open";
  9894. } elsif ($db[0] == 4) {
  9895. push @event, "3:state:tilted";
  9896. } elsif ($db[0] == 5) {
  9897. push @event, "3:state:AI,B0";
  9898. push @event, "3:channelA:AI";
  9899. push @event, "3:channelB:B0";
  9900. push @event, "3:energyBow:pressed";
  9901. } elsif ($db[0] == 6) {
  9902. CommandDeleteReading(undef, "$name channel.*");
  9903. push @event, "3:state:pressed34";
  9904. push @event, "3:energyBow:pressed";
  9905. } elsif ($db[0] == 7) {
  9906. push @event, "3:state:A0,B0";
  9907. push @event, "3:channelA:A0";
  9908. push @event, "3:channelB:B0";
  9909. push @event, "3:energyBow:pressed";
  9910. } elsif ($db[0] == 8) {
  9911. if (AttrVal($name, "sensorMode", "switch") eq "pushbutton") {
  9912. push @event, "3:state:pressed";
  9913. }
  9914. push @event, "3:energyBow:pressed";
  9915. } elsif ($db[0] == 9) {
  9916. push @event, "3:state:AI,BI";
  9917. push @event, "3:channelA:AI";
  9918. push @event, "3:channelB:BI";
  9919. push @event, "3:energyBow:pressed";
  9920. } elsif ($db[0] == 10) {
  9921. push @event, "3:state:A0,BI";
  9922. push @event, "3:channelA:A0";
  9923. push @event, "3:channelB:BI";
  9924. push @event, "3:energyBow:pressed";
  9925. } elsif ($db[0] == 11) {
  9926. push @event, "3:state:BI";
  9927. push @event, "3:channelB:BI";
  9928. push @event, "3:energyBow:pressed";
  9929. } elsif ($db[0] == 12) {
  9930. push @event, "3:state:B0";
  9931. push @event, "3:channelB:B0";
  9932. push @event, "3:energyBow:pressed";
  9933. } elsif ($db[0] == 13) {
  9934. push @event, "3:state:AI";
  9935. push @event, "3:channelA:AI";
  9936. push @event, "3:energyBow:pressed";
  9937. } elsif ($db[0] == 14) {
  9938. push @event, "3:state:A0";
  9939. push @event, "3:channelA:A0";
  9940. push @event, "3:energyBow:pressed";
  9941. } elsif ($db[0] == 15) {
  9942. if (AttrVal($name, "sensorMode", "switch") eq "pushbutton") {
  9943. push @event, "3:state:released";
  9944. }
  9945. push @event, "3:energyBow:released";
  9946. }
  9947. } elsif ($st =~ m/^blindsCtrl\.0[01]$/) {
  9948. # EEP D2-05-0x
  9949. my $channel = (($db[0] & 0xF0) >> 4) + 1;
  9950. my $cmd = $db[0] & 0x0F;
  9951. if ($cmd == 4) {
  9952. # actuator status response
  9953. if ($db[3] == 0) {
  9954. push @event, "3:state:open";
  9955. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":open";
  9956. push @event, "3:position" . sprintf('%02d', $channel) . ":" . $db[3];
  9957. push @event, "3:position:" . $db[3];
  9958. } elsif ($db[3] == 100) {
  9959. push @event, "3:state:closed";
  9960. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":closed";
  9961. push @event, "3:position" . sprintf('%02d', $channel) . ":" . $db[3];
  9962. push @event, "3:position:" . $db[3];
  9963. } elsif ($db[3] == 127) {
  9964. push @event, "3:state:unknown";
  9965. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":unknown";
  9966. push @event, "3:position" . sprintf('%02d', $channel) . ":unknown";
  9967. push @event, "3:position:" . $db[3];
  9968. } else {
  9969. push @event, "3:state:" . $db[3];
  9970. push @event, "3:endPosition" . sprintf('%02d', $channel) . ":not_reached";
  9971. push @event, "3:position" . sprintf('%02d', $channel) . ":" . $db[3];
  9972. push @event, "3:position:" . $db[3];
  9973. }
  9974. if ($db[2] == 127) {
  9975. push @event, "3:anglePos" . sprintf('%02d', $channel) . ":unknown";
  9976. } else {
  9977. push @event, "3:anglePos" . sprintf('%02d', $channel) . ":" . $db[2];
  9978. push @event, "3:anglePos:" . $db[2];
  9979. }
  9980. if ($db[1] == 0) {
  9981. push @event, "3:block" . sprintf('%02d', $channel) . ":unlock";
  9982. } elsif ($db[1] == 1) {
  9983. push @event, "3:block" . sprintf('%02d', $channel) . ":lock";
  9984. } elsif ($db[1] == 2) {
  9985. push @event, "3:block" . sprintf('%02d', $channel) . ":alarm";
  9986. } else {
  9987. push @event, "3:block" . sprintf('%02d', $channel) . ":reserved";
  9988. }
  9989. } else {
  9990. # unknown response
  9991. }
  9992. } elsif ($st eq "multisensor.01") {
  9993. #####
  9994. # Multisensor Windows Handle
  9995. # (D2-06-01)
  9996. # message type
  9997. my $msgType = hex(substr($data, 0, 2));
  9998. my $blinkInterval = 0;
  9999. my $updateInterval = 0;
  10000. my $waitingCmds = ReadingsVal($name, "waitingCmds", undef);
  10001. if ($msgType == 0) {
  10002. # sensor values
  10003. my %onOffTrigger = (
  10004. 0 => "off",
  10005. 1 => "on",
  10006. 14 => "invalid",
  10007. 15 => "not_supported",
  10008. );
  10009. my $onOffTrigger = $db[8] >> 4;
  10010. if (exists $onOffTrigger{$onOffTrigger}) {
  10011. push @event, "3:burglaryAlarm:$onOffTrigger{$onOffTrigger}";
  10012. } else {
  10013. push @event, "3:burglaryAlarm:unknown";
  10014. }
  10015. $onOffTrigger = $db[8] & 15;
  10016. if (exists $onOffTrigger{$onOffTrigger}) {
  10017. push @event, "3:protectionAlarm:$onOffTrigger{$onOffTrigger}";
  10018. } else {
  10019. push @event, "3:protectionAlarm:unknown";
  10020. }
  10021. my %handlePosition = (
  10022. 0 => "unknown",
  10023. 1 => "up",
  10024. 2 => "down",
  10025. 3 => "left",
  10026. 4 => "right",
  10027. 14 => "invalid",
  10028. 15 => "not_supported"
  10029. );
  10030. my %handleRPS = (
  10031. 1 => 'D0',
  10032. 2 => 'F0',
  10033. 3 => 'E0',
  10034. 4 => 'E0'
  10035. );
  10036. my $handlePosition = $db[7] >> 4;
  10037. if (exists $handlePosition{$handlePosition}) {
  10038. push @event, "3:handle:$handlePosition{$handlePosition}";
  10039. } else {
  10040. push @event, "3:handle:unknown";
  10041. }
  10042. # forward handle position (RPS telegam)
  10043. if (exists($handleRPS{$handlePosition}) && defined(AttrVal($name, "subDefH", undef))) {
  10044. EnOcean_SndRadio(undef, $hash, $packetType, "F6", $handleRPS{$handlePosition}, AttrVal($name, "subDefH", "00000000"), '20', 'FFFFFFFF');
  10045. }
  10046. my %windowState = (
  10047. 0 => "undef",
  10048. 1 => "not_tilted",
  10049. 2 => "tilted",
  10050. 14 => "invalid",
  10051. 15 => "not_supported"
  10052. );
  10053. my %window1BS = (
  10054. 1 => '09',
  10055. 2 => '08'
  10056. );
  10057. my $windowState = $db[7] & 15;
  10058. if (exists $windowState{$windowState}) {
  10059. push @event, "3:window:$windowState{$windowState}";
  10060. } else {
  10061. push @event, "3:window:unknown";
  10062. }
  10063. # forward window state (1BS telegam)
  10064. if (exists($window1BS{$windowState}) && defined(AttrVal($name, "subDefW", undef))) {
  10065. EnOcean_SndRadio(undef, $hash, $packetType, "D5", $window1BS{$windowState}, AttrVal($name, "subDefW", "00000000"), '00', 'FFFFFFFF');
  10066. }
  10067. my %button = (
  10068. 0 => "no_change",
  10069. 1 => "pressed",
  10070. 2 => "released",
  10071. 14 => "invalid",
  10072. 15 => "not_supported"
  10073. );
  10074. my $button = $db[6] >> 4;
  10075. if (exists $button{$button}) {
  10076. if ($button == 0 && ReadingsVal($name, "buttonRight", 'unknown') eq 'unknown') {
  10077. push @event, "3:buttonRight:unknown";
  10078. } elsif ($button == 0) {
  10079. } else {
  10080. push @event, "3:buttonRight:$button{$button}";
  10081. }
  10082. } else {
  10083. push @event, "3:buttonRight:unknown";
  10084. }
  10085. $button = $db[6] & 15;
  10086. if (exists $button{$button}) {
  10087. if ($button == 0 && ReadingsVal($name, "buttonLeft", 'unknown') eq 'unknown') {
  10088. push @event, "3:buttonLeft:unknown";
  10089. } elsif ($button == 0) {
  10090. } else {
  10091. push @event, "3:buttonLeft:$button{$button}";
  10092. }
  10093. } else {
  10094. push @event, "3:buttonLeft:unknown";
  10095. }
  10096. my $motion = $db[5] >> 4;
  10097. if (exists $onOffTrigger{$motion}) {
  10098. push @event, "3:motion:$onOffTrigger{$motion}";
  10099. } else {
  10100. push @event, "3:motion:unknown";
  10101. }
  10102. my %vacation = (
  10103. 0 => "no_change",
  10104. 1 => "absent",
  10105. 2 => "present",
  10106. 14 => "invalid",
  10107. 15 => "not_supported"
  10108. );
  10109. my $vacation = $db[5] & 15;
  10110. if (exists $vacation{$vacation}) {
  10111. if ($vacation == 0 && ReadingsVal($name, "presence", 'unknown') eq 'unknown') {
  10112. push @event, "3:presence:unknown";
  10113. } elsif ($vacation == 0) {
  10114. } else {
  10115. push @event, "3:presence:$vacation{$vacation}";
  10116. }
  10117. } else {
  10118. push @event, "3:presence:unknown";
  10119. }
  10120. my $temperature;
  10121. if ($db[4] <= 250) {
  10122. $temperature = sprintf "%0.1f", $db[4] * 80 / 250 - 20;
  10123. push @event, "3:temperature:$temperature";
  10124. } elsif ($db[4] <= 254) {
  10125. $temperature = '-';
  10126. push @event, "3:temperature:invalid";
  10127. } elsif ($db[4] <= 255) {
  10128. $temperature = '-';
  10129. push @event, "3:temperature:not_supported";
  10130. } else {
  10131. $temperature = '-';
  10132. push @event, "3:temperature:unknown";
  10133. }
  10134. my $humidity;
  10135. if ($db[3] <= 200) {
  10136. $humidity = $db[3] / 2;
  10137. push @event, "3:humidity:$humidity";
  10138. } elsif ($db[3] <= 254) {
  10139. $humidity = '-';
  10140. push @event, "3:humidity:invalid";
  10141. } elsif ($db[3] <= 255) {
  10142. $humidity = '-';
  10143. push @event, "3:humidity:not_supported";
  10144. } else {
  10145. $humidity = '-';
  10146. push @event, "3:humidity:unknown";
  10147. }
  10148. my $brightness = hex(substr($data, 14, 4));
  10149. if ($brightness <= 60000) {
  10150. push @event, "3:brightness:$brightness";
  10151. } elsif ($brightness == 60001) {
  10152. $brightness = '-';
  10153. push @event, "3:brightness:over_range";
  10154. } elsif ($brightness == 65534) {
  10155. $brightness = '-';
  10156. push @event, "3:brightness:invalid";
  10157. } elsif ($brightness == 65535) {
  10158. $brightness = '-';
  10159. push @event, "3:brightness:not_supported";
  10160. } else {
  10161. $brightness = '-';
  10162. push @event, "3:brightness:unknown";
  10163. }
  10164. my $energyStorage = ($db[0] >> 3) * 5;
  10165. my $battery;
  10166. if ($energyStorage <= 5) {
  10167. $battery = 'low';
  10168. push @event, "3:battery:low";
  10169. push @event, "3:energyStorage:$energyStorage";
  10170. } elsif ($energyStorage <= 100) {
  10171. $battery = 'ok';
  10172. push @event, "3:battery:ok";
  10173. push @event, "3:energyStorage:$energyStorage";
  10174. } else {
  10175. $battery = '-';
  10176. push @event, "3:battery:-";
  10177. $energyStorage = '-';
  10178. push @event, "3:energyStorage:unknown";
  10179. }
  10180. push @event, "3:state:T: $temperature H: $humidity E: $brightness M: $onOffTrigger{$motion}";
  10181. } elsif ($msgType == 0x10) {
  10182. # configuration report
  10183. if (defined $waitingCmds) {
  10184. $waitingCmds = $db[3] & 0x80 ? $waitingCmds & 0xDF | 32 : $waitingCmds & 0xDF;
  10185. }
  10186. push @event, "3:presence:" . ($db[3] & 0x80 ? 'absent' : 'present');
  10187. push @event, "3:handleClosedClick:" . ($db[3] & 0x40 ? 'enabled' : 'disabled');
  10188. push @event, "3:batteryLowClick:" . ($db[3] & 0x20 ? 'enabled' : 'disabled');
  10189. $updateInterval = hex(substr($data, 4, 4));
  10190. if ($updateInterval <= 4) {
  10191. $updateInterval = '-';
  10192. push @event, "3:updateInterval:unknown";
  10193. } else {
  10194. push @event, "3:updateInterval:$updateInterval";
  10195. }
  10196. $blinkInterval = $db[0];
  10197. if ($blinkInterval <= 2) {
  10198. $blinkInterval = '-';
  10199. push @event, "3:blinkInterval:unknown";
  10200. } else {
  10201. push @event, "3:blinkInterval:$blinkInterval";
  10202. }
  10203. } elsif ($msgType == 0x20) {
  10204. # log data 01
  10205. push @event, "3:powerOns:" . substr($data, 2, 8);
  10206. push @event, "3:alarms:" . substr($data, 10, 8);
  10207. } elsif ($msgType == 0x21) {
  10208. # log data 02
  10209. push @event, "3:handleMoveClosed:" . substr($data, 2, 8);
  10210. push @event, "3:handleMoveOpend:" . substr($data, 10, 8);
  10211. push @event, "3:handleMoveTilted:" . substr($data, 18, 8);
  10212. } elsif ($msgType == 0x22) {
  10213. # log data 03
  10214. push @event, "3:windowTilts:" . substr($data, 2, 8);
  10215. } elsif ($msgType == 0x23) {
  10216. # log data 04
  10217. push @event, "3:buttonRightPresses:" . substr($data, 2, 8);
  10218. push @event, "3:buttonLeftPresses:" . substr($data, 10, 8);
  10219. } else {
  10220. }
  10221. if (defined $waitingCmds) {
  10222. $updateInterval = 0;
  10223. $blinkInterval = 0;
  10224. if ($waitingCmds & 1) {
  10225. $waitingCmds &= 0xFE;
  10226. $updateInterval = ReadingsVal($name, "updateIntervalSet", 0);
  10227. $updateInterval = $updateInterval =~ m/^\d+$/ ? $updateInterval : 0;
  10228. $blinkInterval = ReadingsVal($name, "blinkIntervalSet", 0);
  10229. $blinkInterval = $blinkInterval =~ m/^\d+$/ ? $blinkInterval : 0;
  10230. CommandDeleteReading(undef, "$name .*Set");
  10231. }
  10232. CommandDeleteReading(undef, "$name waitingCmds");
  10233. $data = sprintf "80%02X%04X%02X", $waitingCmds, $updateInterval, $blinkInterval;
  10234. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  10235. #EnOcean_multisensor_01Snd($crtl, $hash, $packetType);
  10236. }
  10237. } elsif ($st eq "roomCtrlPanel.01") {
  10238. # Room Control Panel
  10239. # (D2-11-01 - D2-11-08)
  10240. my $msgType = hex(substr($data, 1, 1));
  10241. my $setpointType = ReadingsVal($name, "setpointType", 'setpointShift');
  10242. my $waitingCmds = ReadingsVal($name, "waitingCmds", 0);
  10243. if (($waitingCmds & 0x80) == 0) {
  10244. $setpointType = hex(substr($data, 0, 1)) & 8 ? 'setpointTemp' : 'setpointShift';
  10245. push @event, "3:setpointType:$setpointType";
  10246. }
  10247. if ($msgType == 2) {
  10248. my $trigger = ($db[5] & 0x60) >> 5;
  10249. my %trigger = (0 => 'heartbeat', 1 => 'sensor', 2 => 'input');
  10250. push @event, "3:trigger:" . $trigger{$trigger};
  10251. my $temperature = sprintf "%0.1f", $db[4] / 255 * 40;
  10252. push @event, "3:temperature:$temperature";
  10253. my $humidity = sprintf "%d", $db[3] / 2.5;
  10254. push @event, "3:humidity:$humidity";
  10255. my $setpointShiftMax = ($db[0] & 0xF0) >> 4;
  10256. push @event, "3:setpointShiftMax:$setpointShiftMax";
  10257. my $setpointShift = int(0.5 + $db[2] * $setpointShiftMax / 128 * 10) / 10 - $setpointShiftMax;
  10258. push @event, "3:setpointShift:" . sprintf "%0.1f", $setpointShift;
  10259. push @event, "3:setpointBase:$db[1]";
  10260. push @event, "3:setpointTemp:" . sprintf "%0.1f", ($db[1] + $setpointShift);
  10261. my %fanSpeed = (0 => 'auto', 1 => 'off', 2 => 1, 3 => 2, 4 => 3);
  10262. my $fanSpeed = ($db[0] & 0xE) >> 1;
  10263. push @event, "3:fanSpeed:" . $fanSpeed{$fanSpeed};
  10264. push @event, "3:occupancy:" . ($db[0] & 1 ? 'occupied' : 'unoccupied');
  10265. push @event, "3:state:T: $temperature H: $humidity SPT: " . ($db[1] + $setpointShift) . " F: " . $fanSpeed{$fanSpeed};
  10266. }
  10267. CommandDeleteReading(undef, "$name waitingCmds");
  10268. } elsif ($st eq "fanCtrl.00") {
  10269. # Fan Control
  10270. # (D2-20-00 - D2-20-02)
  10271. if ($db[3] & 1) {
  10272. # fan status message
  10273. my $fanSpeed = $db[0];
  10274. my $humidity = $db[1];
  10275. my $roomSize = $db[2] & 15;
  10276. my $roomSizeRef = ($db[2] & 0x30) >> 4;
  10277. my $humidityCtrl = ($db[2] & 0xC0) >> 6;
  10278. my $serviceInfo = ($db[3] & 14) >> 1;
  10279. my $opMode = ($db[3] & 0xF0) >> 4;
  10280. my %roomSizeTbl = (
  10281. 0 => 25,
  10282. 1 => 50,
  10283. 2 => 75,
  10284. 3 => 100,
  10285. 4 => 125,
  10286. 5 => 150,
  10287. 6 => 175,
  10288. 7 => 200,
  10289. 8 => 225,
  10290. 9 => 250,
  10291. 10 => 275,
  10292. 11 => 300,
  10293. 12 => 325,
  10294. 13 => 350,
  10295. 14 => "max",
  10296. 15 => "no_change"
  10297. );
  10298. if ($opMode == 0) {
  10299. push @event, "3:state:off";
  10300. } elsif ($opMode == 1) {
  10301. push @event, "3:state:on";
  10302. } elsif ($opMode == 15) {
  10303. push @event, "3:state:not_supported";
  10304. }
  10305. if ($serviceInfo == 0) {
  10306. push @event, "3:error:ok";
  10307. } elsif ($serviceInfo == 1) {
  10308. push @event, "3:error:air_filter";
  10309. } elsif ($serviceInfo == 2) {
  10310. push @event, "3:error:hardware";
  10311. } elsif ($serviceInfo == 7) {
  10312. push @event, "3:error:not_supported";
  10313. }
  10314. if ($humidityCtrl == 0) {
  10315. push @event, "3:humidityCtrl:disabled";
  10316. } elsif ($humidityCtrl == 1) {
  10317. push @event, "3:humidityCtrl:enabled";
  10318. } elsif ($humidityCtrl == 3) {
  10319. push @event, "3:humidityCtrl:not_supported";
  10320. }
  10321. if ($roomSizeRef == 0) {
  10322. push @event, "3:roomSizeRef:used";
  10323. } elsif ($roomSizeRef == 1) {
  10324. push @event, "3:roomSizeRef:not_used";
  10325. } elsif ($roomSizeRef == 3) {
  10326. push @event, "3:roomSizeRef:not_supported";
  10327. }
  10328. if ($roomSize < 15) {
  10329. push @event, "3:roomSize:" . $roomSizeTbl{$roomSize};
  10330. }
  10331. if ($humidity >= 0 && $humidity <= 100) {
  10332. push @event, "3:humidity:$humidity";
  10333. } elsif ($humidity == 255) {
  10334. push @event, "3:humidity:not_supported";
  10335. }
  10336. if ($fanSpeed >= 0 && $fanSpeed <= 100) {
  10337. push @event, "3:fanSpeed:$fanSpeed";
  10338. } elsif ($fanSpeed == 255) {
  10339. push @event, "3:fanSpeed:not_supported";
  10340. }
  10341. }
  10342. } elsif ($st eq "currentClamp.00") {
  10343. # AC current clamp (EEP D2-32-00)
  10344. if ($db[2] & 0x80) {
  10345. # power fail
  10346. push @event, "3:current1:0";
  10347. push @event, "3:state:I1: 0";
  10348. } else {
  10349. my $current1 = hex(substr($data, 2, 3));
  10350. if ($db[2] & 0x40) {
  10351. # divisor = 1/10
  10352. $current1 = $current1 / 10;
  10353. push @event, "3:current1:" . sprintf "%0.1f", $current1;
  10354. push @event, "3:state:I1: " . sprintf "%0.1f", $current1;
  10355. } else {
  10356. push @event, "3:current1:" . $current1;
  10357. push @event, "3:state:I1: " . $current1;
  10358. }
  10359. }
  10360. } elsif ($st eq "currentClamp.01") {
  10361. # AC current clamp (EEP D2-32-01)
  10362. if ($db[3] & 0x80) {
  10363. # power fail
  10364. push @event, "3:current1:0";
  10365. push @event, "3:current2:0";
  10366. push @event, "3:state:I1: 0 I2: 0";
  10367. } else {
  10368. my $current1 = hex(substr($data, 2, 3));
  10369. my $current2 = hex(substr($data, 5, 3));
  10370. if ($db[3] & 0x40) {
  10371. # divisor = 1/10
  10372. $current1 = $current1 / 10;
  10373. $current2 = $current2 / 10;
  10374. push @event, "3:current1:" . sprintf "%0.1f", $current1;
  10375. push @event, "3:current2:" . sprintf "%0.1f", $current2;
  10376. push @event, "3:state:I1: " . sprintf("%0.1f", $current1) . " I2: " . sprintf("%0.1f", $current2);
  10377. } else {
  10378. push @event, "3:current1:" . $current1;
  10379. push @event, "3:current2:" . $current2;
  10380. push @event, "3:state:I1: $current1 I2: $current2";
  10381. }
  10382. }
  10383. } elsif ($st eq "currentClamp.02") {
  10384. # AC current clamp (EEP D2-32-02)
  10385. if ($db[5] & 0x80) {
  10386. # power fail
  10387. push @event, "3:current1:0";
  10388. push @event, "3:current2:0";
  10389. push @event, "3:current3:0";
  10390. push @event, "3:state:I1: 0 I2: 0 I3: 0";
  10391. } else {
  10392. my $current1 = hex(substr($data, 2, 3));
  10393. my $current2 = hex(substr($data, 5, 3));
  10394. my $current3 = hex(substr($data, 8, 3));
  10395. if ($db[5] & 0x40) {
  10396. # divisor = 1/10
  10397. $current1 = $current1 / 10;
  10398. $current2 = $current2 / 10;
  10399. $current3 = $current3 / 10;
  10400. push @event, "3:current1:" . sprintf "%0.1f", $current1;
  10401. push @event, "3:current2:" . sprintf "%0.1f", $current2;
  10402. push @event, "3:current3:" . sprintf "%0.1f", $current3;
  10403. push @event, "3:state:I1: " . sprintf("%0.1f", $current1) . " I2: " . sprintf("%0.1f", $current2) . " I3: " . sprintf("%0.1f", $current3);
  10404. } else {
  10405. push @event, "3:current1:" . $current1;
  10406. push @event, "3:current2:" . $current2;
  10407. push @event, "3:current3:" . $current3;
  10408. push @event, "3:state:I1: $current1 I2: $current2 I3: $current3";
  10409. }
  10410. }
  10411. } elsif ($st eq "ledCtrlState.00") {
  10412. # LED Controller Status (EEP D2-40-00)
  10413. if ($db[1] & 0x80) {
  10414. # powerSwitch
  10415. push @event, "3:powerSwitch:on";
  10416. push @event, "3:state:on";
  10417. } else {
  10418. push @event, "3:powerSwitch:off";
  10419. push @event, "3:state:off";
  10420. }
  10421. if ($db[1] & 0x40) {
  10422. # Demand Response Mode
  10423. push @event, "3:demandResp:on";
  10424. } else {
  10425. push @event, "3:demandResp:off";
  10426. }
  10427. if ($db[1] & 0x20) {
  10428. # Daylight Harvesting
  10429. push @event, "3:daylightHarvesting:on";
  10430. } else {
  10431. push @event, "3:daylightHarvesting:off";
  10432. }
  10433. my $occupancy = ($db[1] & 0x18) >> 3;
  10434. if ($occupancy == 0) {
  10435. push @event, "3:occupany:unoccupied";
  10436. } elsif ($occupancy == 1) {
  10437. push @event, "3:occupany:occupied";
  10438. } else {
  10439. push @event, "3:occupany:unknown";
  10440. }
  10441. push @event, "3:telegramType:" . ($db[1] & 4 ? "event" : "heartbeat");
  10442. if ($db[0] >= 0 && $db[0] <= 200) {
  10443. push @event, "3:dim:" . sprintf "%0.1f", $db[0] / 2;
  10444. }
  10445. } elsif ($st eq "ledCtrlState.01") {
  10446. # LED Controller Status (EEP D2-40-01)
  10447. if ($db[3] & 0x80) {
  10448. # powerSwitch
  10449. push @event, "3:powerSwitch:on";
  10450. push @event, "3:state:on";
  10451. } else {
  10452. push @event, "3:powerSwitch:off";
  10453. push @event, "3:state:off";
  10454. }
  10455. if ($db[3] & 0x40) {
  10456. # Demand Response Mode
  10457. push @event, "3:demandResp:on";
  10458. } else {
  10459. push @event, "3:demandResp:off";
  10460. }
  10461. if ($db[3] & 0x20) {
  10462. # Daylight Harvesting
  10463. push @event, "3:daylightHarvesting:on";
  10464. } else {
  10465. push @event, "3:daylightHarvesting:off";
  10466. }
  10467. my $occupancy = ($db[3] & 0x18) >> 3;
  10468. if ($occupancy == 0) {
  10469. push @event, "3:occupany:unoccupied";
  10470. } elsif ($occupancy == 1) {
  10471. push @event, "3:occupany:occupied";
  10472. } else {
  10473. push @event, "3:occupany:unknown";
  10474. }
  10475. push @event, "3:telegramType:" . ($db[3] & 4 ? "event" : "heartbeat");
  10476. my ($red, $green, $blue) = ('00', '00', '00');
  10477. if ($db[2] >= 0 && $db[2] <= 200) {
  10478. push @event, "3:red:" . sprintf "%0.1f", $db[2] / 2;
  10479. $red = sprintf "%02X", abs($db[2] / 200 * 255);
  10480. }
  10481. if ($db[1] >= 0 && $db[1] <= 200) {
  10482. push @event, "3:green:" . sprintf "%0.1f", $db[1] / 2;
  10483. $green = sprintf "%02X", abs($db[1] / 200 * 255);
  10484. }
  10485. if ($db[0] >= 0 && $db[0] <= 200) {
  10486. push @event, "3:blue:" . sprintf "%0.1f", $db[0] / 2;
  10487. $blue = sprintf "%02X", abs($db[0] / 200 * 255);
  10488. }
  10489. push @event, "3:rgb:" . $red . $green . $blue;
  10490. } elsif ($st eq "heatRecovery.00") {
  10491. # heat recovery ventilation
  10492. # (D2-50-00)
  10493. my $msgType = hex(substr($data, 0, 1)) >> 1;
  10494. if ($msgType == 2) {
  10495. my $ventilation = 'unknown';
  10496. my %ventilation = (
  10497. 0 => "off",
  10498. 1 => 1,
  10499. 2 => 2,
  10500. 3 => 3,
  10501. 4 => 4,
  10502. 11 => "auto",
  10503. 12 => "demand",
  10504. 13 => "supplyAir",
  10505. 14 => "exhaustAir"
  10506. );
  10507. $ventilation = $db[13] & 15;
  10508. $ventilation = $ventilation{$ventilation} if (exists $ventilation{$ventilation});
  10509. push @event, "3:ventilation:$ventilation";
  10510. push @event, "3:fireplaceSafetyMode:" . ($db[12] & 8 ? 'enabled' : 'disabled');
  10511. push @event, "3:heatExchangerBypass:" . ($db[12] & 4 ? 'opened' : 'closed');
  10512. push @event, "3:supplyAirFlap:" . ($db[12] & 2 ? 'opened' : 'closed');
  10513. push @event, "3:exhaustAirFlap:" . ($db[12] & 1 ? 'opened' : 'closed');
  10514. push @event, "3:defrost:" . ($db[11] & 0x80 ? 'on' : 'off');
  10515. push @event, "3:coolingProtection:" . ($db[11] & 0x40 ? 'on' : 'off');
  10516. push @event, "3:outdoorAirHeater:" . ($db[11] & 0x20 ? 'on' : 'off');
  10517. push @event, "3:supplyAirHeater:" . ($db[11] & 0x10 ? 'on' : 'off');
  10518. push @event, "3:drainHeater:" . ($db[11] & 8 ? 'on' : 'off');
  10519. push @event, "3:timerMode:" . ($db[11] & 4 ? 'on' : 'off');
  10520. push @event, "3:filterMaintenance:" . ($db[11] & 2 ? 'required' : 'not_required');
  10521. push @event, "3:weeklyTimer:" . ($db[11] & 1 ? 'on' : 'off');
  10522. push @event, "3:roomTempCtrl:" . ($db[10] & 0x80 ? 'on' : 'off');
  10523. my $airQuatity = $db[10] & 0x7F;
  10524. if ($airQuatity <= 100) {
  10525. push @event, "3:airQuality1:$airQuatity";
  10526. } else {
  10527. CommandDeleteReading(undef, "$name airQuality1");
  10528. }
  10529. push @event, "3:deviceMode:" . ($db[9] & 0x80 ? 'slave' : 'master');
  10530. $airQuatity = $db[9] & 0x7F;
  10531. if ($airQuatity <= 100) {
  10532. push @event, "3:airQuality2:$airQuatity";
  10533. } else {
  10534. CommandDeleteReading(undef, "$name airQuality2");
  10535. }
  10536. my $outdoorTemp = ($db[8] & 0xFE) >> 1;
  10537. $outdoorTemp -= $outdoorTemp if ($outdoorTemp & 0x40);
  10538. push @event, "3:outdoorTemp:$outdoorTemp";
  10539. my $supplyTemp = ($db[8] & 1) << 6 | ($db[7] & 0xFC) >> 2;
  10540. $supplyTemp -= $supplyTemp if ($supplyTemp & 0x40);
  10541. push @event, "3:supplyTemp:$supplyTemp";
  10542. my $roomTemp = ($db[7] & 3) << 5 | ($db[6] & 0xF8) >> 3;
  10543. $roomTemp -= $roomTemp if ($roomTemp & 0x40);
  10544. push @event, "3:roomTemp:$roomTemp";
  10545. my $exhaustTemp = ($db[6] & 7) << 4 | ($db[5] & 0xF0) >> 4;
  10546. $exhaustTemp -= $exhaustTemp if ($exhaustTemp & 0x40);
  10547. push @event, "3:exhaustTemp:$exhaustTemp";
  10548. push @event, "3:supplyAirFlow:". (($db[5] & 0x0F) << 2 | ($db[4] & 0xFC) >> 2);
  10549. push @event, "3:exhaustAirFlow:" . (($db[4] & 3) << 8 | $db[3]);
  10550. push @event, "3:supplyFanSpeed:". ($db[2] << 4 | ($db[1] & 0xF0) >> 4);
  10551. push @event, "3:exhaustFanSpeed:" . (($db[1] & 0x0F) << 8 | $db[0]);
  10552. push @event, "3:state:$ventilation";
  10553. } elsif ($msgType == 3) {
  10554. push @event, "3:SWVersion:" . (($db[13] & 0x0F) << 8 | $db[12]);
  10555. push @event, "3:operationHours:" . (($db[11] << 8 | $db[10]) * 3);
  10556. push @event, "3:input:" . sprintf("%02b %02b", $db[9], $db[8]);
  10557. push @event, "3:output:" . sprintf("%02b %02b", $db[7], $db[6]);
  10558. push @event, "3:info:" . sprintf("%02b %02b", $db[5], $db[4]);
  10559. push @event, "3:fault:" . sprintf("%02b %02b %02b %02b", $db[3], $db[2], $db[1], $db[0]);
  10560. }
  10561. } elsif ($st eq "valveCtrl.00") {
  10562. # Valve Control
  10563. # (D2-A0-01)
  10564. $db[0] &= 3;
  10565. if (AttrVal($name, "devMode", "master") eq "slave") {
  10566. # devMode slave
  10567. if ($db[0] == 1 || $db[0] == 3) {
  10568. push @event, "3:state:closes";
  10569. } elsif ($db[0] == 2) {
  10570. push @event, "3:state:opens";
  10571. } elsif ($db[0] == 0) {
  10572. my $state = ReadingsVal($name, "state", "-");
  10573. if ($state eq "closed" || $state eq "closes") {
  10574. $state = "01";
  10575. } elsif ($state eq "open" || $state eq "opens") {
  10576. $state = "02";
  10577. } else {
  10578. $state = "00";
  10579. }
  10580. EnOcean_SndRadio(undef, $hash, 1, "D2", $state, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  10581. }
  10582. } else {
  10583. #devMode master
  10584. if ($db[0] == 1) {
  10585. push @event, "3:state:closed";
  10586. } elsif ($db[0] == 2) {
  10587. push @event, "3:state:open";
  10588. } elsif ($db[0] == 0 || $db[0] == 3) {
  10589. push @event, "3:state:-";
  10590. }
  10591. }
  10592. } elsif ($st eq "liquidLeakage.51") {
  10593. # liquid leakage sensor
  10594. push @event, "3:state:" . $db[0] & 3 ? 'wet' : 'dry';
  10595. } elsif ($st eq "raw") {
  10596. # raw
  10597. push @event, "3:state:RORG: $rorg DATA: $data STATUS: $status ODATA: $odata";
  10598. # display data bytes $db[0] ... $db[x]
  10599. for (my $dbCntr = 0; $dbCntr <= $#db; $dbCntr++) {
  10600. push @event, "3:DB_" . $dbCntr . ":" . $db[$dbCntr];
  10601. }
  10602. } else {
  10603. # unknown devices
  10604. push @event, "3:state:$data";
  10605. }
  10606. } elsif ($rorg eq "D1") {
  10607. # MSC telegram
  10608. if ($st eq "actuator.01") {
  10609. if ($manufID eq "033") {
  10610. if (substr($data, 3, 1) == 4) {
  10611. my $getParam = ReadingsVal($name, "getParam", 0);
  10612. if ($getParam == 8) {
  10613. push @event, "3:loadClassification:no";
  10614. push @event, "3:loadLink:" . ($db[1] & 16 ? "connected" : "disconnected");
  10615. push @event, "3:loadOperation:3-wire";
  10616. push @event, "3:loadState:" . ($db[1] & 64 ? "on" : "off");
  10617. CommandDeleteReading(undef, "$name getParam");
  10618. } elsif ($getParam == 7) {
  10619. if ($db[0] & 4) {
  10620. push @event, "3:devTempState:warning";
  10621. } elsif ($db[0] & 2) {
  10622. push @event, "3:devTempState:max";
  10623. } else {
  10624. push @event, "3:devTempState:ok";
  10625. }
  10626. push @event, "3:mainsPower:" . ($db[0] & 8 ? "failure" : "ok");
  10627. if ($db[1] == 0xFF) {
  10628. push @event, "3:devTemp:invalid";
  10629. } else {
  10630. push @event, "3:devTemp:" . $db[1];
  10631. }
  10632. CommandDeleteReading(undef, "$name getParam");
  10633. } elsif ($getParam == 9) {
  10634. push @event, "3:voltage:" . sprintf("%.2f", (hex(substr($data, 4, 4)) * 0.01));
  10635. CommandDeleteReading(undef, "$name getParam");
  10636. } elsif ($getParam == 0x81) {
  10637. $hash->{READINGS}{serialNumber}{VAL} = substr($data, 4, 4);
  10638. $hash->{READINGS}{getParam}{VAL} = 0x82;
  10639. EnOcean_SndRadio(undef, $hash, $packetType, "D1", "033182", AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  10640. } elsif ($getParam == 0x82) {
  10641. push @event, "3:serialNumber:" . $hash->{READINGS}{serialNumber}{VAL} . substr($data, 4, 4);
  10642. CommandDeleteReading(undef, "$name getParam");
  10643. }
  10644. }
  10645. } elsif ($manufID eq "046") {
  10646. my $cmd = hex(substr($data, 4, 2));
  10647. if ($cmd == 3) {
  10648. push @event, "3:firmwareVersion:" . substr($data, 6, 6);
  10649. } elsif ($cmd == 5) {
  10650. push @event, "3:taughtInDevNum:$db[0]";
  10651. } elsif ($cmd == 7) {
  10652. CommandDeleteReading(undef, "$name taughtInDevID.*");
  10653. push @event, "3:taughtInDevID" . sprintf('%02d', $db[4]) . ":" . substr($data, 8, 8);
  10654. }
  10655. }
  10656. } elsif ($st eq "raw") {
  10657. # raw
  10658. push @event, "3:state:RORG: $rorg DATA: $data STATUS: $status ODATA: $odata";
  10659. push @event, "3:manufID:" . substr($data, 0, 3);
  10660. # display data bytes $db[0] ... $db[x]
  10661. for (my $dbCntr = 0; $dbCntr <= $#db; $dbCntr++) {
  10662. push @event, "3:DB_" . $dbCntr . ":" . $db[$dbCntr];
  10663. }
  10664. } else {
  10665. # unknown devices
  10666. if(AttrVal($name, "blockUnknownMSC", "no") eq "yes") {
  10667. push @event, "3:MSC:$data";
  10668. }
  10669. }
  10670. } elsif ($rorg eq "D0") {
  10671. my %smartAckMailbox = (0 => 'empty', 1 => 'not_exits', 2 => 'reset');
  10672. push @event, "3:smartAckMailbox:" . $smartAckMailbox{$db[0]};
  10673. } elsif ($rorg eq "B2") {
  10674. # GP complete data (GPCD)
  10675. my ($channel, $channelName, $value, $gpDef, $resolution) = (0, undef, undef, AttrVal($name, 'gpDef', undef), undef);
  10676. return "generic profil not defined" if (!defined $gpDef);
  10677. my @gpDef = split("[ \t][ \t]*", $gpDef);
  10678. my ($readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType);
  10679. $data = EnOcean_convHexToBit($data);
  10680. while (defined $gpDef[$channel]) {
  10681. ($channelName, undef, undef, undef, undef, $resolution, undef, undef, undef, undef) = split(':', $gpDef[$channel]);
  10682. $resolution = 0 if (!defined $resolution);
  10683. $data =~ m/^(.{$EnO_resolution[$resolution]})(.*)$/;
  10684. $value = hex(unpack('H8', pack('B32', '0' x (32 - $EnO_resolution[$resolution]) . $1)));
  10685. $data = $2;
  10686. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType)=
  10687. EnOcean_gpConvDataToValue (undef, $hash, $channel, $value, $gpDef[$channel]);
  10688. $channel ++;
  10689. next if (defined $err);
  10690. push @event, "3:$readingName:" . sprintf("$readingFormat", $readingValue);
  10691. push @event, "3:" . $readingName . "Unit:$readingUnit";
  10692. push @event, "3:" . $readingName . "ValueType:$valueType";
  10693. push @event, "3:" . $readingName . "ChannelType:$readingType";
  10694. }
  10695. } elsif ($rorg eq "B3") {
  10696. # GP selective data (GPSD)
  10697. my $gpDef = AttrVal($name, "gpDef", undef);
  10698. return "generic profil not defined" if (!defined $gpDef);
  10699. my @gpDef = split("[ \t][ \t]*", $gpDef);
  10700. my ($channel, $channelName, $resolution, $value);
  10701. my ($readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType);
  10702. #Log3 $name, 2, "EnOcean $name parse GPSD data: $data start";
  10703. $data =~ m/^(.)(.*)$/;
  10704. my $header = hex $1;
  10705. $data = substr(EnOcean_convHexToBit($data), 4);
  10706. #Log3 $name, 2, "EnOcean $name parse GPSD header: $header data: $data start";
  10707. for (my $cntr = 1; $cntr <= $header; $cntr ++) {
  10708. $data =~ m/^(.{6})(.*)$/;
  10709. ($channel, $data) = (unpack('C', pack('B8', '00' . $1)), $2);
  10710. #Log3 $name, 2, "EnOcean $name parse GPSD channel: $channel data: $data";
  10711. if (defined $gpDef[$channel]) {
  10712. ($channelName, undef, undef, undef, undef, $resolution, undef, undef, undef, undef) = split(':', $gpDef[$channel]);
  10713. $resolution = 0 if (!defined $resolution || $resolution eq '');
  10714. $data =~ m/^(.{$EnO_resolution[$resolution]})(.*)$/;
  10715. $value = hex(unpack('H8', pack('B32', '0' x (32 - $EnO_resolution[$resolution]) . $1)));
  10716. $data = $2;
  10717. #Log3 $name, 2, "EnOcean $name parse GPSD channel: $channel value: " . $value . " data: $data";
  10718. ($err, $logLevel, $response, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType) =
  10719. EnOcean_gpConvDataToValue(undef, $hash, $channel, $value, $gpDef[$channel]);
  10720. push @event, "3:$readingName:" . sprintf("$readingFormat", $readingValue);
  10721. push @event, "3:" . $readingName . "Unit:$readingUnit";
  10722. push @event, "3:" . $readingName . "ValueType:$valueType";
  10723. push @event, "3:" . $readingName . "ChannelType:$readingType";
  10724. }
  10725. }
  10726. } elsif ($rorg eq "B0" && $teach) {
  10727. # GP teach in request (GPTI)
  10728. #
  10729. $data =~ m/^(....)(.*)$/;
  10730. my $header = hex($1);
  10731. $data = $2;
  10732. my $purpose = ($header & 12) >> 2;
  10733. if ($purpose == 0 || ($purpose == 2 && AttrVal($name, "subType", "") ne "genericProfile")) {
  10734. # teach-in request
  10735. $attr{$name}{comMode} = $header & 16 ? "biDir" : "uniDir";
  10736. $attr{$name}{eep} = "B0-00-00";
  10737. $attr{$name}{manufID} = sprintf "%03X", ($header & 0xFFE0) >> 5;
  10738. $attr{$name}{subType} = "genericProfile";
  10739. $attr{$name}{teachMethod} = 'GP';
  10740. my $channel = 0;
  10741. my $channelDir = "I";
  10742. my $channelDef;
  10743. my $channelName;
  10744. my $channelType;
  10745. my $cntr = 0;
  10746. my $dataOutboundDefLen = 0;
  10747. my @gpDef;
  10748. my $signalType;
  10749. #Log3 $name, 2, "EnOcean $name parse GPTI header: $header data: $data start";
  10750. $data = EnOcean_convHexToBit($data);
  10751. #Log3 $name, 2, "EnOcean $name parse GPTI data: $data start";
  10752. while (length($data) >= 12) {
  10753. last if ($cntr > 64);
  10754. $cntr ++;
  10755. $data =~ m/^(..)(.{8})(.*)$/;
  10756. $channelType = unpack('C', pack('B8', '000000' . $1));
  10757. $signalType = unpack('C', pack('B8', $2));
  10758. $data = $3;
  10759. #Log3 $name, 2, "EnOcean $name parse GPTI channel: $channel channelType: $channelType signalType: $signalType data: $data";
  10760. if ($channelType == 0) {
  10761. # teach-in information
  10762. if ($signalType == 1) {
  10763. # outbound channel description
  10764. $channelDir = "O";
  10765. $data =~ m/^(.{8})(.*)$/;
  10766. $dataOutboundDefLen = unpack('C', pack('B8', $1));
  10767. $data = $2;
  10768. } elsif ($signalType == 2) {
  10769. # produkt ID
  10770. $data =~ m/^(.{32})(.*)$/;
  10771. $attr{$name}{productID} = EnOcean_convBitToHex($1);
  10772. $data = $2;
  10773. }
  10774. } elsif ($channelType == 1) {
  10775. # data
  10776. $data =~ m/^(..)(....)(.{8})(....)(.{8})(....)(.*)$/;
  10777. $channelDef = $channelDir . ':' . $channelType . ':' . $signalType . ':' .
  10778. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2)) . ':' .
  10779. unpack('c', pack('B8', $3)) . ':' . unpack('C', pack('B8', '0000' . $4)) . ':' .
  10780. unpack('c', pack('B8', $5)) . ':' . unpack('C', pack('B8', '0000' . $6));
  10781. $data = $7;
  10782. if (defined $EnO_gpValueData{$signalType}{name}) {
  10783. $channelName = $EnO_gpValueData{$signalType}{name};
  10784. } else {
  10785. $channelName = "none";
  10786. }
  10787. $gpDef[$channel] = $channelName . ':' . $channelDef;
  10788. $channel ++;
  10789. } elsif ($channelType == 2) {
  10790. # flag
  10791. $data =~ m/^(..)(.*)$/;
  10792. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  10793. unpack('C', pack('B8', '000000' . $1));
  10794. $data = $2;
  10795. if (defined $EnO_gpValueFlag{$signalType}{name}) {
  10796. $channelName = $EnO_gpValueFlag{$signalType}{name};
  10797. } else {
  10798. $channelName = "none";
  10799. }
  10800. $gpDef[$channel] = $channelName . ':' . $channelDef;
  10801. $channel ++;
  10802. } elsif ($channelType == 3) {
  10803. # enumeration
  10804. $data =~ m/^(..)(....)(.*)$/;
  10805. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  10806. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2));
  10807. $data = $3;
  10808. if (defined $EnO_gpValueEnum{$signalType}{name}) {
  10809. $channelName = $EnO_gpValueEnum{$signalType}{name};
  10810. } else {
  10811. $channelName = "none";
  10812. }
  10813. $gpDef[$channel] = $channelName . ':' . $channelDef;
  10814. $channel ++;
  10815. }
  10816. }
  10817. $attr{$name}{gpDef} = join(' ', @gpDef);
  10818. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  10819. # send GP Teach-In Response message
  10820. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", "biDir");
  10821. $data = sprintf "%04X", ((hex(AttrVal($name, "manufID", "7FF")) << 5) | 8);
  10822. EnOcean_SndCdm(undef, $hash, $packetType, "B1", $data, $subDef, "00", $senderID);
  10823. Log3 $name, 2, "EnOcean $name GP teach-in response sent to $senderID";
  10824. }
  10825. my $mid = $attr{$name}{manufID};
  10826. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10827. push @event, "3:teach:GP teach-in accepted Manufacturer: $mid";
  10828. Log3 $name, 2, "EnOcean $name GP teach-in accepted Manufacturer: $mid";
  10829. # store attr subType, manufID, gpDef ...
  10830. EnOcean_CommandSave(undef, undef);
  10831. } elsif ($purpose == 1 || ($purpose == 2 && AttrVal($name, "subType", "") eq "genericProfile")) {
  10832. # teach-in deletion request
  10833. $deleteDevice = $name;
  10834. if (AttrVal($name, "comMode", "uniDir") eq "biDir") {
  10835. # send GP Teach-In Deletion Response message
  10836. $data = sprintf "%04X", (hex(AttrVal($name, "manufID", "7FF")) << 5) | 16;
  10837. EnOcean_SndCdm(undef, $hash, $packetType, "B1", $data, AttrVal($name, "subDef", "00000000"), "00", $senderID);
  10838. Log3 $name, 2, "EnOcean $name GP teach-in deletion response send to $senderID";
  10839. }
  10840. Log3 $name, 2, "EnOcean $name GP teach-in delete request executed";
  10841. }
  10842. } elsif ($rorg eq "B1" && $teach) {
  10843. # GP teach-in response (GPTR)
  10844. $data =~ m/^(....)(.*)$/;
  10845. my $header = hex($1);
  10846. $data = $2;
  10847. my $mid = sprintf "%03X", ($header & 0xFFE0) >> 5;
  10848. my $purpose = ($header & 24) >> 3;
  10849. if (exists $hash->{IODev}{helper}{gpRespWait}{$destinationID}) {
  10850. if ($purpose == 0) {
  10851. # teach-in rejected generally
  10852. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "in") {
  10853. push @event, "3:teach:GP teach-in rejected";
  10854. Log3 $name, 2, "EnOcean $name GP teach-in rejected by $senderID";
  10855. }
  10856. # clear teach-in request
  10857. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10858. } elsif ($purpose == 1) {
  10859. # teach-in accepted
  10860. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "in") {
  10861. $attr{$name}{manufID} = $mid;
  10862. # substitute subDef with DEF
  10863. $attr{$name}{subDef} = $hash->{DEF};
  10864. $hash->{DEF} = $senderID;
  10865. $modules{EnOcean}{defptr}{$senderID} = $hash;
  10866. delete $modules{EnOcean}{defptr}{$destinationID};
  10867. EnOcean_CommandSave(undef, undef);
  10868. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10869. push @event, "3:teach:GP teach-in accepted Manufacturer: $mid";
  10870. Log3 $name, 2, "EnOcean $name GP teach-in accepted by $senderID";
  10871. }
  10872. # clear teach-in request
  10873. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10874. } elsif ($purpose == 2) {
  10875. # teach-out accepted
  10876. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "out") {
  10877. if (defined $attr{$name}{subDef}) {
  10878. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  10879. $hash->{DEF} = $attr{$name}{subDef};
  10880. $modules{EnOcean}{defptr}{$hash->{DEF}} = $hash;
  10881. delete $attr{$name}{subDef};
  10882. EnOcean_CommandSave(undef, undef);
  10883. }
  10884. push @event, "3:teach:GP teach-out accepted";
  10885. Log3 $name, 2, "EnOcean $name GP teach-out accepted";
  10886. }
  10887. # clear teach-in request
  10888. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10889. } else {
  10890. if ($hash->{IODev}{helper}{gpRespWait}{$destinationID}{teachInReq} eq "in") {
  10891. # rejected channels outbound or inbound, sent teach-in response with teach-out
  10892. $data = sprintf "%04X", (hex(AttrVal($name, "manufID", "7FF")) << 5) | 16;
  10893. EnOcean_SndCdm(undef, $hash, $packetType, "B1", $data, $destinationID, "00", $senderID);
  10894. push @event, "3:teach:GP teach-in channels rejected, sent teach-out";
  10895. Log3 $name, 2, "EnOcean $name GP teach-in channels rejected, sent teach-out to $senderID";
  10896. }
  10897. # clear teach-in request
  10898. delete $hash->{IODev}{helper}{gpRespWait}{$destinationID};
  10899. }
  10900. } else {
  10901. Log3 $name, 2, "EnOcean $name GP teach-in response from $senderID received, teach-in request unknown";
  10902. }
  10903. } elsif ($rorg eq "D4" && $teach) {
  10904. # UTE - Universal Uni- and Bidirectional Teach-In / Teach-Out
  10905. #
  10906. Log3 $name, 5, "EnOcean $name UTE teach-in received from $senderID";
  10907. my $rorg = sprintf "%02X", $db[0];
  10908. my $func = sprintf "%02X", $db[1];
  10909. my $type = sprintf "%02X", $db[2];
  10910. my $mid = sprintf "%03X", ((($db[3] & 7) << 8) | $db[4]);
  10911. my $devChannel = $db[5];
  10912. my $comMode = $db[6] & 0x80 ? "biDir" : "uniDir";
  10913. my $comModeUTE = AttrVal($hash->{IODev}{NAME}, "comModeUTE", "auto");
  10914. $comMode = $comModeUTE if ($comModeUTE ne 'auto');
  10915. my $subType = "$rorg.$func.$type";
  10916. if (($db[6] & 0xF) == 0) {
  10917. # Teach-In Query telegram received
  10918. my $teachInReq = ($db[6] & 0x30) >> 4;
  10919. if ($teachInReq == 0 || $teachInReq == 2) {
  10920. # Teach-In Request
  10921. $attr{$name}{teachMethod} = 'UTE';
  10922. if(exists $EnO_eepConfig{$subType}) {
  10923. # Teach-In EEP supported
  10924. foreach my $attrCntr (keys %{$EnO_eepConfig{$subType}{attr}}) {
  10925. $attr{$name}{$attrCntr} = $EnO_eepConfig{$subType}{attr}{$attrCntr};
  10926. }
  10927. $attr{$name}{manufID} = $mid;
  10928. $attr{$name}{devChannel} = $devChannel;
  10929. $attr{$name}{comMode} = $comMode;
  10930. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10931. $attr{$name}{eep} = "$rorg-$func-$type";
  10932. if (exists($hash->{helper}{teachInWait}) && $hash->{helper}{teachInWait} =~ m/^UTE|STE$/) {
  10933. $attr{$filelogName}{logtype} = $EnO_eepConfig{$subType}{GPLOT} . 'text'
  10934. if (exists $attr{$filelogName}{logtype});
  10935. EnOcean_CreateSVG(undef, $hash, undef);
  10936. delete $hash->{helper}{teachInWait};
  10937. }
  10938. $subType = $EnO_eepConfig{$subType}{attr}{subType};
  10939. #$attr{$name}{subType} = $subType;
  10940. push @event, "3:teach:UTE teach-in accepted EEP $rorg-$func-$type Manufacturer: $mid";
  10941. if (!($db[6] & 0x40)) {
  10942. # UTE Teach-In-Response expected
  10943. # send UTE Teach-In Response message
  10944. $data = (sprintf "%02X", $db[6] & 0x80 | 0x11) . substr($data, 2, 12);
  10945. if ($comMode eq "biDir") {
  10946. ($err, $subDef) = EnOcean_AssignSenderID(undef, $hash, "subDef", $comMode);
  10947. } else {
  10948. $subDef = "00000000";
  10949. }
  10950. EnOcean_SndRadio(undef, $hash, $packetType, "D4", $data, $subDef, "00", $senderID);
  10951. Log3 $name, 2, "EnOcean $name UTE teach-in response send to $senderID";
  10952. }
  10953. Log3 $name, 2, "EnOcean $name UTE teach-in accepted EEP $rorg-$func-$type Manufacturer: $mid";
  10954. } else {
  10955. # Teach-In EEP not supported
  10956. $attr{$name}{subType} = "raw";
  10957. $attr{$name}{manufID} = $mid;
  10958. $attr{$name}{devChannel} = $devChannel;
  10959. $attr{$name}{comMode} = $comMode;
  10960. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  10961. push @event, "3:teach:UTE teach-in accepted EEP $rorg-$func-$type not supported Manufacturer: $mid";
  10962. # send EEP Teach-In Response message
  10963. if (!($db[6] & 0x40)) {
  10964. # UTE Teach-In-Response expected
  10965. # send UTE Teach-In Response message
  10966. $data = (sprintf "%02X", $db[6] & 0x80 | 0x31) . substr($data, 2, 12);
  10967. EnOcean_SndRadio(undef, $hash, $packetType, "D4", $data, "00000000", "00", $senderID);
  10968. Log3 $name, 2, "EnOcean $name UTE teach-in response send to $senderID";
  10969. }
  10970. Log3 $name, 2, "EnOcean $name UTE teach-in accepted EEP $rorg-$func-$type not supported Manufacturer: $mid";
  10971. }
  10972. # store attr subType, manufID ...
  10973. EnOcean_CommandSave(undef, undef);
  10974. } elsif ($teachInReq == 1) {
  10975. # Teach-In Deletion Request
  10976. $deleteDevice = $name;
  10977. if (!($db[6] & 0x40)) {
  10978. # UTE Teach-In Deletion Response expected
  10979. # send UTE Teach-In Deletion Response message
  10980. $data = (sprintf "%02X", $db[6] & 0x80 | 0x21) . substr($data, 2, 12);
  10981. EnOcean_SndRadio(undef, $hash, $packetType, "D4", $data, AttrVal($name, "subDef", "00000000"), "00", $senderID);
  10982. Log3 $name, 2, "EnOcean $name UTE teach-in deletion response send to $senderID";
  10983. }
  10984. Log3 $name, 2, "EnOcean $name UTE teach-in delete request executed";
  10985. }
  10986. } else {
  10987. # Teach-In Respose telegram received
  10988. my $teachInAccepted = ($db[6] & 0x30) >> 4;
  10989. Log3 $name, 5, "EnOcean $name UTE teach-in response message from $senderID received";
  10990. if (exists $hash->{IODev}{helper}{UTERespWait}{$destinationID}) {
  10991. if ($comMode eq "uniDir") {
  10992. $attr{$name}{manufID} = $mid;
  10993. if ($teachInAccepted == 0) {
  10994. $teachInAccepted = "request not accepted";
  10995. } elsif ($teachInAccepted == 1){
  10996. $teachInAccepted = "teach-in accepted";
  10997. } elsif ($teachInAccepted == 2){
  10998. $teachInAccepted = "teach-out accepted";
  10999. } else {
  11000. $teachInAccepted = "EEP not supported";
  11001. }
  11002. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  11003. push @event, "3:teach:UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11004. Log3 $name, 2, "EnOcean $name UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11005. } else {
  11006. if ($hash->{IODev}{helper}{UTERespWait}{$destinationID}{teachInReq} eq "in") {
  11007. # Teach-In Request
  11008. if ($teachInAccepted == 0) {
  11009. $teachInAccepted = "request not accepted";
  11010. } elsif ($teachInAccepted == 1){
  11011. $teachInAccepted = "teach-in accepted";
  11012. $attr{$name}{subDef} = $hash->{DEF};
  11013. $hash->{DEF} = $senderID;
  11014. $modules{EnOcean}{defptr}{$senderID} = $hash;
  11015. delete $modules{EnOcean}{defptr}{$destinationID};
  11016. $attr{$name}{manufID} = $mid;
  11017. # store attr subType, manufID ...
  11018. EnOcean_CommandSave(undef, undef);
  11019. } elsif ($teachInAccepted == 2){
  11020. $teachInAccepted = "teach-out accepted";
  11021. } else {
  11022. $teachInAccepted = "EEP not supported";
  11023. }
  11024. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  11025. push @event, "3:teach:UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11026. Log3 $name, 2, "EnOcean $name UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11027. } elsif ($hash->{IODev}{helper}{UTERespWait}{$destinationID}{teachInReq} eq "out") {
  11028. # Teach-In Deletion Request
  11029. if ($teachInAccepted == 0) {
  11030. $teachInAccepted = "request not accepted";
  11031. } elsif ($teachInAccepted == 1){
  11032. $teachInAccepted = "teach-in accepted";
  11033. } elsif ($teachInAccepted == 2){
  11034. $teachInAccepted = "teach-out accepted";
  11035. if (defined $attr{$name}{subDef}) {
  11036. delete $modules{EnOcean}{defptr}{$hash->{DEF}};
  11037. $hash->{DEF} = $attr{$name}{subDef};
  11038. $modules{EnOcean}{defptr}{$hash->{DEF}} = $hash;
  11039. delete $attr{$name}{subDef};
  11040. EnOcean_CommandSave(undef, undef);
  11041. }
  11042. } else {
  11043. $teachInAccepted = "EEP not supported";
  11044. }
  11045. $mid = $EnO_manuf{$mid} if($EnO_manuf{$mid});
  11046. push @event, "3:teach:UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11047. Log3 $name, 2, "EnOcean $name UTE $teachInAccepted EEP $rorg-$func-$type Manufacturer: $mid";
  11048. }
  11049. }
  11050. # clear teach-in request
  11051. delete $hash->{IODev}{helper}{UTERespWait}{$destinationID};
  11052. } else {
  11053. # teach-in request unknown, delete response device, no action
  11054. $deleteDevice = $name;
  11055. Log3 $name, 2, "EnOcean $name UTE teach-in request unknown";
  11056. }
  11057. }
  11058. } elsif ($rorg eq "35" && $teach) {
  11059. # Secure Teach-In
  11060. ($err, $msg) = EnOcean_sec_parseTeachIn($hash, $data, $subDef, $destinationID);
  11061. if (defined $err) {
  11062. Log3 $name, 2, "EnOcean $name secure teach-in ERROR: $err";
  11063. return "";
  11064. }
  11065. Log3 $name, 3, "EnOcean $name secure teach-in $msg";
  11066. EnOcean_CommandSave(undef, undef);
  11067. return "";
  11068. } elsif ($rorg eq "C6" && $smartAckLearn) {
  11069. # Smart Ack Learn Request
  11070. #####
  11071. $data =~ m/^(....)(..)(..)(..)(..)(........)$/;
  11072. my $subType = "$2.$3.$4";
  11073. my $postmasterID = '0' x 8;
  11074. my $mid = '7FF';
  11075. my $responseTime = 150;
  11076. my $sendData = '';
  11077. if (exists $EnO_eepConfig{$subType}) {
  11078. if (($db[9] & 0xF8) == 0xF8) {
  11079. # Smart Ack send by sensor
  11080. $attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType};
  11081. $attr{$name}{eep} = "$3-$4-$5";
  11082. $mid = substr(sprintf("%04X", hex($1) & 0x7FF), 1);
  11083. $attr{$name}{manufID} = $mid;
  11084. $mid = $EnO_manuf{$mid} if(exists $EnO_manuf{$mid});
  11085. $attr{$name}{repeaterID} = $6;
  11086. $postmasterID = $6;
  11087. $attr{$name}{postmasterID} = $postmasterID;
  11088. $attr{$name}{teachMethod} = 'smartAck';
  11089. $hash->{SmartAckRSSI} = - hex($db[4]);
  11090. foreach my $attrCntr (keys %{$EnO_eepConfig{$subType}{attr}}) {
  11091. if ($attrCntr ne "subDef") {
  11092. $attr{$name}{$attrCntr} = $EnO_eepConfig{$subType}{attr}{$attrCntr};
  11093. }
  11094. }
  11095. if (defined AttrVal($name, 'subDef', undef)) {
  11096. $subDef = $attr{$name}{subDef};
  11097. } else {
  11098. $subDef = EnOcean_CheckSenderID('getNextID', $hash->{IODev}{NAME}, "00000000");
  11099. $attr{$name}{subDef} = $subDef;
  11100. }
  11101. # create mailbox
  11102. $sendData = sprintf "03%04X00%04X%04X", $responseTime, $postmasterID, $hash->{DEF};
  11103. EnOcean_SndRadio(undef, $hash, 6, $rorg, $sendData, $subDef, '00', $hash->{DEF});
  11104. # next commands will be sent with a delay
  11105. #usleep($responseTime * 1000);
  11106. # send learn reply
  11107. $sendData = sprintf "01%04X00%04X", $responseTime, $hash->{DEF};
  11108. EnOcean_SndRadio(undef, $hash, 1, 'C7', $sendData, $subDef, '00', $hash->{DEF});
  11109. push @event, "3:teach:Smart Ack teach-in accepted EEP " . $attr{$name}{eep} . " Manufacturer: $mid";
  11110. Log3 $name, 2, "EnOcean $name Smart Ack teach-in accepted EEP " . $attr{$name}{eep} . " Manufacturer: $mid";
  11111. EnOcean_CommandSave(undef, undef);
  11112. }
  11113. } else {
  11114. # EEP not supported
  11115. # send learn reply
  11116. $sendData = sprintf "01%04X10%04X", $responseTime, $hash->{DEF};
  11117. EnOcean_SndRadio(undef, $hash, 1, 'C7', $sendData, '0' x 8, '00', $hash->{DEF});
  11118. CommandDelete(undef, $name);
  11119. Log3 $name, 2, "EnOcean $name Smart Ack teach-in not accepted EEP " . $attr{$name}{eep} . " Manufacturer: $mid";
  11120. }
  11121. } elsif ($packetType == 7) {
  11122. # packet type REMOTE_MAN_COMMAND
  11123. my $remoteCode = AttrVal($name, 'remoteCode', '0' x 8);
  11124. my $remoteLastStatusReturnCode = $manufID eq '7FF' ? '00' : '04';
  11125. my $remoteManagement = AttrVal($name, "remoteManagement", "off");
  11126. my $sendData = '';
  11127. push @event, "3:remoteLastFunctionNumber:" . sprintf("%03X", $funcNumber);
  11128. if ($funcNumber == 1 && $remoteManagement eq 'client') {
  11129. # unlock
  11130. if ($data eq uc($remoteCode) && !exists($hash->{RemoteClientUnlockFailed})) {
  11131. $hash->{RemoteClientUnlock} = 1;
  11132. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  11133. RemoveInternalTimer(\%functionHash);
  11134. InternalTimer(gettimeofday() + 1800, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  11135. Log3 $name, 2, "EnOcean $name RMCC unlock request executed.";
  11136. } else {
  11137. $remoteLastStatusReturnCode = '02';
  11138. $hash->{RemoteClientUnlockFailed} = 1;
  11139. my %functionHash = (hash => $hash, param => 'RemoteClientUnlockFailed');
  11140. RemoveInternalTimer(\%functionHash);
  11141. InternalTimer(gettimeofday() + 30, 'EnOcean_cdmClearHashVal', \%functionHash, 0);
  11142. Log3 $name, 2, "EnOcean $name RMCC unlock request not executed, remote Code $data wrong.";
  11143. }
  11144. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11145. } elsif ($funcNumber == 2 && $remoteManagement eq 'client') {
  11146. # lock
  11147. if ($hash->{RemoteClientUnlock} && $data eq uc($remoteCode)) {
  11148. delete $hash->{RemoteClientUnlock};
  11149. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  11150. RemoveInternalTimer(\%functionHash);
  11151. Log3 $name, 2, "EnOcean $name RMCC lock request executed.";
  11152. } else {
  11153. $remoteLastStatusReturnCode = '02';
  11154. Log3 $name, 2, "EnOcean $name RMCC lock request not executed.";
  11155. }
  11156. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11157. } elsif ($funcNumber == 3 && $remoteManagement eq 'client') {
  11158. # set code
  11159. if ($hash->{RemoteClientUnlock} && $data =~ m/^[A-Fa-f0-9]{8}$/ && uc($data) ne 'FFFFFFFF') {
  11160. $attr{$name}{remoteCode} = $data;
  11161. EnOcean_CommandSave(undef, undef);
  11162. Log3 $name, 2, "EnOcean $name RMCC set code request executed.";
  11163. } else {
  11164. $remoteLastStatusReturnCode = '05';
  11165. Log3 $name, 2, "EnOcean $name RMCC set code request not executed.";
  11166. }
  11167. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11168. } elsif ($funcNumber == 4 && $remoteManagement eq 'client') {
  11169. # query ID
  11170. if ($hash->{RemoteClientUnlock}) {
  11171. my $eepRcv = hex(substr($data, 0, 6)) >> 3;
  11172. my $rorg = sprintf "%02X", ($eepRcv >> 13);
  11173. my $func = sprintf "%02X", (($eepRcv & 0x1F80) >> 7);
  11174. my $type = sprintf "%02X", ($eepRcv & 127);
  11175. $eepRcv = "$rorg-$func-$type";
  11176. if ($hash->{RemoteClientUnlock} && $eep eq $eepRcv) {
  11177. $sendData = '06040' . AttrVal($name, 'manufID', '7FF') . substr($data, 0, 4) . sprintf("%02X", hex(substr($data, 4, 2)) & 0xF8);
  11178. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11179. Log3 $name, 2, "EnOcean $name RMCC query ID answer sent.";
  11180. } else {
  11181. $remoteLastStatusReturnCode = '03';
  11182. Log3 $name, 2, "EnOcean $name RMCC query ID request not executed, EEP $eepRcv wrong or client locked.";
  11183. }
  11184. } else {
  11185. $remoteLastStatusReturnCode = '07';
  11186. Log3 $name, 2, "EnOcean $name RMCC query ID request not executed.";
  11187. }
  11188. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11189. } elsif ($funcNumber == 5 && $remoteManagement eq 'client') {
  11190. # action
  11191. if ($hash->{RemoteClientUnlock}) {
  11192. Log3 $name, 2, "EnOcean $name RMCC action request executed";
  11193. } else {
  11194. $remoteLastStatusReturnCode = '01';
  11195. Log3 $name, 2, "EnOcean $name RMCC action request not executed.";
  11196. }
  11197. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11198. } elsif ($funcNumber == 6 && $remoteManagement eq 'client') {
  11199. # ping
  11200. my $eep = AttrVal($name, "eep", "C5-00-00");
  11201. if ($eep =~ m/^([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})-([A-Fa-f0-9]{2})$/i) {
  11202. $eep = (((hex($1) << 6) | hex($2)) << 7) | hex($3);
  11203. } else {
  11204. $eep = (((hex("C5") << 6) | hex("00")) << 7) | hex("00");
  11205. }
  11206. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11207. push @event, "3:remoteRSSI:" . -$RSSI;
  11208. $sendData = '06060' . AttrVal($name, 'manufID', '7FF') . sprintf("%04X%02X", $eep << 3, $RSSI);
  11209. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11210. Log3 $name, 2, "EnOcean $name RMCC ping answer executed";
  11211. } elsif ($funcNumber == 7 && $remoteManagement eq 'client') {
  11212. # query function
  11213. if ($hash->{RemoteClientUnlock}) {
  11214. $sendData = '06070' . AttrVal($name, 'manufID', '7FF') . '020107FF';
  11215. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11216. Log3 $name, 2, "EnOcean $name RMCC query function answer sent.";
  11217. } else {
  11218. $remoteLastStatusReturnCode = '07';
  11219. Log3 $name, 2, "EnOcean $name RMCC query function request not executed.";
  11220. }
  11221. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11222. } elsif ($funcNumber == 8 && $remoteManagement eq 'client') {
  11223. # query status
  11224. if ($hash->{RemoteClientUnlock}) {
  11225. $sendData = '06080' . AttrVal($name, 'manufID', '7FF') . '000' . ReadingsVal($name, "remoteLastFunctionNumber", "000") .
  11226. ReadingsVal($name, "$remoteLastStatusReturnCode", '00');
  11227. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11228. Log3 $name, 2, "EnOcean $name RMCC query status answer sent.";
  11229. } else {
  11230. $remoteLastStatusReturnCode = '07';
  11231. Log3 $name, 2, "EnOcean $name RMCC query status request not executed.";
  11232. }
  11233. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11234. } elsif ($funcNumber == 0x201) {
  11235. $data =~ m/^(..)(..)(..)(..)$/;
  11236. my ($rorg, $func, $type, $flag) = ($1, $2, $3, hex($4));
  11237. if ($flag == 1) {
  11238. # learn in
  11239. if (exists $EnO_eepConfig{"$rorg.$func.$type"}) {
  11240. $attr{$name}{eep} = "$rorg-$func-$type";
  11241. #$attr{$name}{remoteID} = $remoteID if (defined $remoteID);
  11242. $attr{$name}{remoteManagement} = "client";
  11243. $attr{$name}{teachMethod} = 'RPC';
  11244. foreach my $attrCntr (keys %{$EnO_eepConfig{"$rorg.$func.$type"}{attr}}) {
  11245. if ($attrCntr eq "subDef") {
  11246. if (!exists $attr{$name}{$attrCntr}) {
  11247. $attr{$name}{$attrCntr} = EnOcean_CheckSenderID($EnO_eepConfig{"$rorg.$func.$type"}{attr}{$attrCntr}, $hash->{IODev}{NAME}, "00000000");
  11248. }
  11249. } else {
  11250. $attr{$name}{$attrCntr} = $EnO_eepConfig{"$rorg.$func.$type"}{attr}{$attrCntr};
  11251. }
  11252. }
  11253. EnOcean_CreateSVG(undef, $hash, $attr{$name}{eep});
  11254. push @event, "3:teach:RPC teach-in accepted EEP $rorg-$func-$type Manufacturer: " .
  11255. (exists($EnO_manuf{$manufID}) ? $EnO_manuf{$manufID} : $manufID);
  11256. Log3 $name, 2, "EnOcean $name RPC teach-in with EEP $rorg-$func-$type ManufacturerID: $manufID accepted.";
  11257. } else {
  11258. Log3 $name, 2, "EnOcean $name RPC teach-in with EEP $rorg-$func-$type ManufacturerID: $manufID not supported.";
  11259. }
  11260. } elsif ($flag == 3) {
  11261. # learn out
  11262. #Log3 $name, 2, "EnOcean $name device $name deleted";
  11263. CommandDelete(undef, $name);
  11264. Log3 $name, 2, "EnOcean $name RPC teach-out with EEP $rorg-$func-$type ManufacturerID: $manufID executed.";
  11265. EnOcean_CommandSave(undef, undef);
  11266. } else {
  11267. Log3 $name, 2, "EnOcean $name RPC learn function $flag not supported";
  11268. }
  11269. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11270. } elsif ($funcNumber == 0x240 && $remoteManagement eq 'manager') {
  11271. # acknowledge
  11272. $remoteLastStatusReturnCode = '00';
  11273. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11274. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11275. Log3 $name, 2, "EnOcean $name RPC acknowledge received";
  11276. } elsif ($funcNumber == 0x604 && $remoteManagement eq 'manager') {
  11277. # query id answer
  11278. my $eep = hex(substr($data, 0, 6)) >> 3;
  11279. my $rorg = sprintf "%02X", ($eep >> 13);
  11280. my $func = sprintf "%02X", (($eep & 0x1F80) >> 7);
  11281. my $type = sprintf "%02X", ($eep & 127);
  11282. $attr{$name}{remoteManufID} = $manufID;
  11283. $manufID = $EnO_manuf{$manufID} if($EnO_manuf{$manufID});
  11284. $attr{$name}{remoteEEP} = "$rorg-$func-$type";
  11285. my $subType = "$rorg.$func.$type";
  11286. #$attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType} if($EnO_manuf{$subType});
  11287. $remoteLastStatusReturnCode = '00';
  11288. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11289. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11290. Log3 $name, 2, "EnOcean $name RMCC query ID answer received EEP $rorg-$func-$type Manufacturer: $manufID";
  11291. EnOcean_CommandSave(undef, undef);
  11292. } elsif ($funcNumber == 0x606 && $remoteManagement eq 'manager') {
  11293. # ping answer
  11294. my $eep = hex(substr($data, 0, 6)) >> 3;
  11295. my $rorg = sprintf "%02X", ($eep >> 13);
  11296. my $func = sprintf "%02X", (($eep & 0x1F80) >> 7);
  11297. my $type = sprintf "%02X", ($eep & 127);
  11298. $attr{$name}{remoteManufID} = $manufID;
  11299. $manufID = $EnO_manuf{$manufID} if($EnO_manuf{$manufID});
  11300. $attr{$name}{remoteEEP} = "$rorg-$func-$type";
  11301. my $subType = "$rorg.$func.$type";
  11302. #$attr{$name}{subType} = $EnO_eepConfig{$subType}{attr}{subType} if($EnO_manuf{$subType});
  11303. push @event, "3:remoteRSSI:" . -$RSSI;
  11304. $remoteLastStatusReturnCode = '00';
  11305. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11306. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11307. Log3 $name, 2, "EnOcean $name RMCC ping answer received EEP $rorg-$func-$type Manufacturer: $manufID";
  11308. EnOcean_CommandSave(undef, undef);
  11309. } elsif ($funcNumber == 0x607 && $remoteManagement eq 'manager') {
  11310. # query function answer
  11311. CommandDeleteReading(undef, "$name remoteFunction.*");
  11312. my $count = 1;
  11313. my $len = length($data);
  11314. while ($len > 0) {
  11315. $data =~ m/^.(...).(...)(.*)$/;
  11316. push @event, "3:remoteFunction" . sprintf("%02d", $count) . ":$1:$2:" . (exists($EnO_extendedRemoteFunctionCode{hex($1)}) ? $EnO_extendedRemoteFunctionCode{hex($1)} : '-');
  11317. $count ++;
  11318. $data = $3;
  11319. $len -= 8;
  11320. }
  11321. $remoteLastStatusReturnCode = '00';
  11322. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11323. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11324. Log3 $name, 2, "EnOcean $name RMCC query function answer received";
  11325. } elsif ($funcNumber == 0x608 && $remoteManagement eq 'manager') {
  11326. # query status answer
  11327. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11328. push @event, "3:remoteLastFunctionNumber:" . substr($data, 3, 3);
  11329. push @event, "3:remoteLastStatusReturnCode:" . substr($data, 6, 2);
  11330. Log3 $name, 2, "EnOcean $name RMCC query status answer received LastFunction: " . substr($data, 3, 3) .
  11331. " LastFunctionCode: " . substr($data, 6, 2);
  11332. } elsif ($funcNumber == 0x810 && $remoteManagement eq 'manager') {
  11333. # teach-in supported link tables response
  11334. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11335. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11336. my $supportFlags = hex(substr($data, 0, 2));
  11337. my $linkTableInCurrent = substr($data, 6, 2) && $supportFlags & 0x10 ? substr($data, 6, 2) : '00';
  11338. my $linkTableInMax = substr($data, 8, 2) && $supportFlags & 0x10 ? substr($data, 8, 2) : '00';
  11339. my $linkTableOutCurrent = substr($data, 2, 2) && $supportFlags & 0x20 ? substr($data, 2, 2) : '00';
  11340. my $linkTableOutMax = substr($data, 4, 2) && $supportFlags & 0x20 ? substr($data, 4, 2) : '00';
  11341. push @event, "3:remoteLearn:" . ($supportFlags & 0x80 ? 'supported' : 'not_supported');
  11342. push @event, "3:remoteLinkTableIn:" . ($supportFlags & 0x10 ? 'supported' : 'not_supported');
  11343. push @event, "3:remoteLinkTableOut:" . ($supportFlags & 0x20 ? 'supported' : 'not_supported');
  11344. push @event, "3:remoteLinkTableInCurrent:" . $linkTableInCurrent if ($supportFlags & 0x10);
  11345. push @event, "3:remoteLinkTableInMax:" . $linkTableInMax if ($supportFlags & 0x10);
  11346. push @event, "3:remoteLinkTableOutCurrent:" . $linkTableOutCurrent if ($supportFlags & 0x20);
  11347. push @event, "3:remoteLinkTableOutMax:" . $linkTableOutMax if ($supportFlags & 0x20);
  11348. push @event, "3:remoteTeach:" . ($supportFlags & 0x40 ? 'supported' : 'not_supported');
  11349. Log3 $name, 2, "EnOcean $name RPC teach-in supported link tables response received Data: $data";
  11350. # request outbound table
  11351. #$hash->{IODev}{helper}{remoteAnswerWait}{0x821}{hash} = $hash;
  11352. #$hash->{IODev}{helper}{remoteLinkTableStartRef} = 0;
  11353. #my %functionHash = (hash => $hash, param => 0x821);
  11354. #RemoveInternalTimer(\%functionHash);
  11355. #InternalTimer(gettimeofday() + 2.5, 'EnOcean_cdmClearRemoteWait', \%functionHash, 0);
  11356. #$sendData = '022107FF';
  11357. #EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11358. #Log3 $name, 2, "EnOcean $name RPC request teach-in outbound table";
  11359. } elsif ($funcNumber == 0x811 && $remoteManagement eq 'manager') {
  11360. # link table response
  11361. CommandDeleteReading(undef, "$name remoteLinkTableDesc.*");
  11362. $data =~ m/^(..)(.*)$/;
  11363. my $direction = hex($1) & 0x80 ? 'Out' : 'In';
  11364. $data = $2;
  11365. while (length($data) > 0) {
  11366. $data =~ m/^(..)(........)(..)(..)(..)(..)(.*)$/;
  11367. push @event, "3:remoteLinkTableDesc" . $direction . "$1:S2:S3-S4-$5:$6";
  11368. $data = $7;
  11369. }
  11370. $remoteLastStatusReturnCode = '00';
  11371. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11372. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11373. Log3 $name, 2, "EnOcean $name RPC link table response received";
  11374. } elsif ($funcNumber == 0x813 && $remoteManagement eq 'manager') {
  11375. # link table GP response
  11376. CommandDeleteReading(undef, "$name remoteLinkTableGPDesc.*");
  11377. $data =~ m/^(..)(.*)$/;
  11378. my $direction = hex($1) & 0x80 ? 'Out' : 'In';
  11379. $data = $2;
  11380. my $channel = 0;
  11381. my $channelDir = hex($1) & 0x80 ? 'O' : 'I';
  11382. my $channelDef;
  11383. my $channelName;
  11384. my $channelType;
  11385. my $dataOutboundDefLen = 0;
  11386. my $gpData;
  11387. my @gpDef;
  11388. my $gpIdx;
  11389. my $signalType;
  11390. while (length($data) > 0) {
  11391. $data =~ m/^(..)(.{12})(.*)$/;
  11392. $gpIdx = $1;
  11393. $gpData = EnOcean_convHexToBit($2);
  11394. $data = $3;
  11395. $gpData =~ m/^(..)(.{8})(.*)$/;
  11396. $channelType = unpack('C', pack('B8', '000000' . $1));
  11397. $signalType = unpack('C', pack('B8', $2));
  11398. $data = $3;
  11399. #Log3 $name, 2, "EnOcean $name parse RPC link table GP idx: $gpIdx channelType: $channelType signalType: $signalType data: $data";
  11400. if ($channelType == 0) {
  11401. # teach-in information
  11402. if ($signalType == 1) {
  11403. # outbound channel description
  11404. } elsif ($signalType == 2) {
  11405. # produkt ID
  11406. }
  11407. } elsif ($channelType == 1) {
  11408. # data
  11409. $gpData =~ m/^(..)(....)(.{8})(....)(.{8})(....)(.*)$/;
  11410. $channelDef = $channelDir . ':' . $channelType . ':' . $signalType . ':' .
  11411. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2)) . ':' .
  11412. unpack('c', pack('B8', $3)) . ':' . unpack('C', pack('B8', '0000' . $4)) . ':' .
  11413. unpack('c', pack('B8', $5)) . ':' . unpack('C', pack('B8', '0000' . $6));
  11414. if (defined $EnO_gpValueData{$signalType}{name}) {
  11415. $channelName = $EnO_gpValueData{$signalType}{name};
  11416. } else {
  11417. $channelName = "none";
  11418. }
  11419. $gpDef[$channel] = $channelName . ':' . $channelDef;
  11420. } elsif ($channelType == 2) {
  11421. # flag
  11422. $gpData =~ m/^(..)(.*)$/;
  11423. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  11424. unpack('C', pack('B8', '000000' . $1));
  11425. if (defined $EnO_gpValueFlag{$signalType}{name}) {
  11426. $channelName = $EnO_gpValueFlag{$signalType}{name};
  11427. } else {
  11428. $channelName = "none";
  11429. }
  11430. $gpDef[$channel] = $channelName . ':' . $channelDef;
  11431. } elsif ($channelType == 3) {
  11432. # enumeration
  11433. $gpData =~ m/^(..)(....)(.*)$/;
  11434. $channelDef = $channelDir . ':' .$channelType . ':' . $signalType . ':' .
  11435. unpack('C', pack('B8', '000000' . $1)) . ':' . unpack('C', pack('B8', '0000' . $2));
  11436. if (defined $EnO_gpValueEnum{$signalType}{name}) {
  11437. $channelName = $EnO_gpValueEnum{$signalType}{name};
  11438. } else {
  11439. $channelName = "none";
  11440. }
  11441. $gpDef[$channel] = $channelName . ':' . $channelDef;
  11442. }
  11443. push @event, "3:remoteLinkTableGPDesc" . $direction . "$gpIdx:$gpDef[0]";
  11444. }
  11445. $remoteLastStatusReturnCode = '00';
  11446. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11447. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11448. Log3 $name, 2, "EnOcean $name RPC link table GP response received";
  11449. } elsif ($funcNumber == 0x827 && $remoteManagement eq 'manager') {
  11450. # product ID answer
  11451. $manufID = substr($data, 1, 3);
  11452. $attr{$name}{remoteManufID} = $manufID;
  11453. $manufID = $EnO_manuf{$manufID} if($EnO_manuf{$manufID});
  11454. $remoteLastStatusReturnCode = '00';
  11455. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11456. $sendData = '024007FF';
  11457. EnOcean_SndRadio(undef, $hash, $packetType, $rorg, $sendData, '0' x 8, '0F', $senderID);
  11458. push @event, "3:remoteProductID:" . substr($data, 4, 8);
  11459. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11460. Log3 $name, 2, "EnOcean $name RPC Product ID answer received ProductID: " . substr($data, 4, 8) . " Manufacturer: $manufID";
  11461. Log3 $name, 2, "EnOcean $name RPC acknowledge sent";
  11462. EnOcean_CommandSave(undef, undef);
  11463. } elsif ($funcNumber == 0x830 && $remoteManagement eq 'manager') {
  11464. # device config response
  11465. CommandDeleteReading(undef, "$name remoteDevCfg.*");
  11466. my $idx;
  11467. my $valueLen;
  11468. while (length($data) > 0) {
  11469. $data =~ m/^(....)(..)(.*)$/;
  11470. $idx = $1;
  11471. $valueLen = hex($2) * 2;
  11472. $data = $3;
  11473. $data =~ m/^(.{$valueLen})(.*)$/;
  11474. push @event, "3:remoteDevCfg$idx:S1";
  11475. $data = $2;
  11476. }
  11477. $remoteLastStatusReturnCode = '00';
  11478. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11479. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11480. Log3 $name, 2, "EnOcean $name RPC device configuration response received";
  11481. } elsif ($funcNumber == 0x832 && $remoteManagement eq 'manager') {
  11482. # link based configuration response
  11483. $data =~ m/^(..)(..)(.*)$/;
  11484. my $direction = hex($1) & 0x80 ? 'Out' : 'In';
  11485. my $linkTableIdx = $2;
  11486. CommandDeleteReading(undef, "$name remoteLinkCfg$direction$linkTableIdx.*");
  11487. $data = $3;
  11488. my $idx;
  11489. my $valueLen;
  11490. while (length($data) > 0) {
  11491. $data =~ m/^(....)(..)(.*)$/;
  11492. $idx = $1;
  11493. $valueLen = hex($2) * 2;
  11494. $data = $3;
  11495. $data =~ m/^(.{$valueLen})(.*)$/;
  11496. push @event, "3:remoteLinkCfg$direction$linkTableIdx:$idx:S1";
  11497. $data = $2;
  11498. }
  11499. $remoteLastStatusReturnCode = '00';
  11500. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11501. push @event, "3:remoteLastStatusReturnCode:$remoteLastStatusReturnCode";
  11502. Log3 $name, 2, "EnOcean $name RPC link table response received";
  11503. } elsif ($funcNumber == 0x850 && $remoteManagement eq 'manager') {
  11504. # query status answer
  11505. delete $iohash->{helper}{remoteAnswerWait}{$funcNumber}{hash};
  11506. my $repeaterFunction = 'off';
  11507. if (($db[0] & 0xC0) == 0) {
  11508. $repeaterFunction = 'off';
  11509. } elsif (($db[0] & 0xC0) == 0x40) {
  11510. $repeaterFunction = 'on';
  11511. } elsif (($db[0] & 0xC0) == 0x80) {
  11512. $repeaterFunction = 'filter';
  11513. }
  11514. push @event, "3:remoteRepeaterFunction:$repeaterFunction";
  11515. push @event, "3:remoteRepeaterLevel:" . (($db[0] & 0x30) == 0x20 ? 2 : 1);
  11516. push @event, "3:remoteRepeaterFilter:" . ($db[0] & 8 ? 'OR' : 'AND');
  11517. Log3 $name, 2, "EnOcean $name RPC repeater functions response received";
  11518. } else {
  11519. Log3 $name, 2, "EnOcean $name RMCC/RPC function number " . sprintf("%03X", $funcNumber) . " not supported.";
  11520. }
  11521. } elsif ($rorg eq "C5" && $packetType == 1) {
  11522. # remote management >> packetType = 7
  11523. return $name;
  11524. }
  11525. readingsBeginUpdate($hash);
  11526. for(my $i = 0; $i < int(@event); $i++) {
  11527. # Flag & 1: reading, Flag & 2: changed. Currently ignored.
  11528. my ($flag, $vn, $vv) = split(':', $event[$i], 3);
  11529. readingsBulkUpdate($hash, $vn, $vv);
  11530. my @cmdObserve = ($name, $vn, $vv);
  11531. EnOcean_observeParse(2, $hash, @cmdObserve);
  11532. }
  11533. readingsEndUpdate($hash, 1);
  11534. if (defined $deleteDevice) {
  11535. # delete device and save config
  11536. CommandDelete(undef, $deleteDevice);
  11537. Log3 $name, 2, "EnOcean $name device $deleteDevice deleted";
  11538. if (defined $oldDevice) {
  11539. Log3 $name, 2, "EnOcean $name renamed $oldDevice to $deleteDevice";
  11540. CommandRename(undef, "$oldDevice $deleteDevice");
  11541. EnOcean_CommandSave(undef, undef);
  11542. return $deleteDevice;
  11543. } else {
  11544. EnOcean_CommandSave(undef, undef);
  11545. return '';
  11546. }
  11547. }
  11548. return $name;
  11549. }
  11550. sub EnOcean_Attr(@)
  11551. {
  11552. my ($cmd, $name, $attrName, $attrVal) = @_;
  11553. my $hash = $defs{$name};
  11554. # return if attribute list is incomplete
  11555. return undef if (!$init_done);
  11556. my $err;
  11557. my $loglevel = 2;
  11558. my $waitingCmds = AttrVal($name, "waitingCmds", 0);
  11559. if ($attrName eq "angleTime") {
  11560. my $channel;
  11561. my $data;
  11562. if (!defined $attrVal) {
  11563. if (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11564. # no rotation
  11565. $data = "7FFF0007F5";
  11566. EnOcean_SndRadio(undef, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11567. }
  11568. } elsif (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11569. my @attrVal = split(':', $attrVal);
  11570. for (my $channel = 0; $channel <= $#attrVal && $channel < 4; $channel ++) {
  11571. if ($attrVal[$channel] =~ m/^\d+(\.\d+)?$/ && $attrVal[$channel] >= 0 && $attrVal[$channel] <= 2.54) {
  11572. if ($attrVal[$channel] < 0.01) {
  11573. $attrVal[$channel] = 0;
  11574. } else {
  11575. $attrVal[$channel] = int($attrVal[$channel] * 100);
  11576. }
  11577. $data = sprintf "7FFF%02X07%02X", $attrVal[$channel], $channel << 4 | 5;
  11578. EnOcean_SndRadio(0.2 + $channel * 0.5, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11579. } else {
  11580. $err = "attribute-value [$attrName] = $attrVal wrong";
  11581. }
  11582. }
  11583. } elsif (AttrVal($name, "subType", "") eq "manufProfile" && AttrVal($name, "manufID", "") eq "00D" &&
  11584. $attrVal =~ m/^[+-]?\d+?$/ && $attrVal >= 1 && $attrVal <= 6) {
  11585. } else {
  11586. $err = "attribute-value [$attrName] = $attrVal wrong";
  11587. #Log3 $name, 2, "EnOcean $name attribute-value [$attrName] = $attrVal wrong";
  11588. #CommandDeleteAttr(undef, "$name $attrName");
  11589. }
  11590. } elsif ($attrName eq "alarmAction") {
  11591. my $data;
  11592. if (!defined $attrVal) {
  11593. if (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11594. # no alarm action
  11595. $data = "7FFFFF00F5";
  11596. EnOcean_SndRadio(undef, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11597. }
  11598. } elsif (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  11599. my @attrVal = split(':', $attrVal);
  11600. for (my $channel = 0; $channel <= $#attrVal && $channel < 4; $channel ++) {
  11601. if ($attrVal =~ m/no|stop|opens|closes$/) {
  11602. my $alarmAction = 0;
  11603. if ($attrVal[$channel] eq "no") {
  11604. $alarmAction = 0;
  11605. } elsif ($attrVal[$channel] eq "stop") {
  11606. $alarmAction = 1;
  11607. } elsif ($attrVal[$channel] eq "opens") {
  11608. $alarmAction = 2;
  11609. } elsif ($attrVal[$channel] eq "closes") {
  11610. $alarmAction = 3;
  11611. } else {
  11612. $err = "attribute-value [$attrName] = $attrVal wrong";
  11613. }
  11614. $data = sprintf "7FFFFF%02X%02X", $alarmAction, $channel << 4 | 5;
  11615. EnOcean_SndRadio(0.2 + $channel * 0.5, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  11616. } else {
  11617. $err = "attribute-value [$attrName] = $attrVal wrong";
  11618. }
  11619. }
  11620. } else {
  11621. $err = "attribute-value [$attrName] = $attrVal wrong";
  11622. }
  11623. } elsif ($attrName =~ m/^block.*/) {
  11624. if (!defined $attrVal){
  11625. } elsif ($attrVal =~ m/^(no|yes)$/) {
  11626. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11627. $waitingCmds |= 64;
  11628. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11629. }
  11630. } else {
  11631. $err = "attribute-value [$attrName] = $attrVal wrong";
  11632. }
  11633. } elsif ($attrName eq "comMode") {
  11634. if (!defined $attrVal){
  11635. } elsif ($attrVal !~ m/^biDir|uniDir|confirm$/) {
  11636. $err = "attribute-value [$attrName] = $attrVal wrong";
  11637. }
  11638. } elsif ($attrName eq "creator") {
  11639. if (!defined $attrVal){
  11640. } elsif ($attrVal !~ m/^autocreate|manual$/) {
  11641. $err = "attribute-value [$attrName] = $attrVal wrong";
  11642. }
  11643. } elsif ($attrName eq "dataEnc") {
  11644. if (!defined $attrVal){
  11645. } elsif ($attrVal !~ m/^VAES|AES-CBC$/) {
  11646. $err = "attribute-value [$attrName] = $attrVal wrong";
  11647. }
  11648. } elsif ($attrName eq "daylightSavingTime") {
  11649. if (!defined $attrVal){
  11650. } elsif ($attrVal =~ m/^(supported|not_supported)$/) {
  11651. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11652. $waitingCmds |= 64;
  11653. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11654. }
  11655. } else {
  11656. $err = "attribute-value [$attrName] = $attrVal wrong";
  11657. }
  11658. } elsif ($attrName eq "defaultChannel") {
  11659. my $defaultChannel = '';
  11660. my $subType = AttrVal($name, "subType", "");
  11661. if ($subType eq "actuator.01") {
  11662. $defaultChannel = join("|", @EnO_defaultChannel);
  11663. } elsif ($subType =~ m/^blindsCtrl\.0[01]$/) {
  11664. $defaultChannel = '[1234]|all';
  11665. }
  11666. if (!defined $attrVal){
  11667. } elsif ($attrVal !~ m/^($defaultChannel)$/) {
  11668. $err = "attribute-value [$attrName] = $attrVal wrong";
  11669. }
  11670. } elsif ($attrName eq "demandRespAction") {
  11671. if (!defined $attrVal){
  11672. } else {
  11673. my %specials = ("%TARGETNAME" => $name,
  11674. "%NAME" => $name,
  11675. "%TARGETTYPE" => '',
  11676. "%TYPE" => '',
  11677. "%LEVEL" => '',
  11678. "%SETPOINT" => '',
  11679. "%POWERUSAGE" => '',
  11680. "%POWERUSAGESCALE" => '',
  11681. "%POWERUSAGELEVEL" => '',
  11682. "%TARGETSTATE" => '',
  11683. "%STATE" => ''
  11684. );
  11685. $err = perlSyntaxCheck($attrVal, %specials);
  11686. }
  11687. } elsif ($attrName eq "demandRespRandomTime") {
  11688. if (!defined $attrVal) {
  11689. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 1) {
  11690. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11691. }
  11692. } elsif ($attrName =~ m/^(demandRespMax|demandRespMin)$/) {
  11693. if (!defined $attrVal){
  11694. } elsif ($attrVal !~ m/^(A0|AI|B0|BI|C0|CI|D0|DI)$/) {
  11695. $err = "attribute-value [$attrName] = $attrVal wrong";
  11696. CommandDeleteAttr(undef, "$name $attrName");
  11697. }
  11698. } elsif ($attrName eq "demandRespThreshold") {
  11699. if (!defined $attrVal) {
  11700. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 0 || $attrVal > 15) {
  11701. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11702. }
  11703. } elsif ($attrName eq "devChannel") {
  11704. if (!defined $attrVal){
  11705. } elsif ($attrVal =~ m/^[\dA-Fa-f]{2}$/) {
  11706. # actions see EnOcean_Notify, global ATTR
  11707. } elsif ($attrVal =~ m/^\d+$/ && $attrVal >= 0 && $attrVal <= 255) {
  11708. } else {
  11709. $err = "attribute-value [$attrName] = $attrVal wrong";
  11710. }
  11711. } elsif ($attrName eq "devMode") {
  11712. if (!defined $attrVal){
  11713. } elsif ($attrVal !~ m/^master|slave$/) {
  11714. $err = "attribute-value [$attrName] = $attrVal wrong";
  11715. }
  11716. } elsif ($attrName eq "devUpdate") {
  11717. if (!defined $attrVal){
  11718. } elsif ($attrVal !~ m/^(off|auto|demand|polling|interrupt)$/) {
  11719. $err = "attribute-value [$attrName] = $attrVal wrong";
  11720. }
  11721. } elsif ($attrName =~ m/^dimMax|dimMin$/) {
  11722. if (!defined $attrVal){
  11723. } elsif ($attrVal !~ m/^off|[\d+]$/) {
  11724. $err = "attribute-value [$attrName] = $attrVal wrong";
  11725. }
  11726. } elsif ($attrName eq "displayContent") {
  11727. if (!defined $attrVal){
  11728. } elsif ($attrVal =~ m/^(humidity|off|setpointTemp|tempertureExtern|temperatureIntern|time|default|no_change)$/) {
  11729. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11730. $waitingCmds |= 64;
  11731. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11732. }
  11733. } else {
  11734. $err = "attribute-value [$attrName] = $attrVal wrong";
  11735. }
  11736. } elsif ($attrName eq "displayOrientation") {
  11737. if (!defined $attrVal){
  11738. } elsif ($attrVal !~ m/^0|90|180|270$/) {
  11739. $err = "attribute-value [$attrName] = $attrVal wrong";
  11740. }
  11741. } elsif ($attrName eq "eep" || $attrName eq "remoteEEP") {
  11742. if (!defined $attrVal){
  11743. } elsif ($attrVal !~ m/^[\dA-Fa-f]{2}-[\dA-Fa-f]{2}-[\dA-Fa-f]{2}$/) {
  11744. $err = "attribute-value [$attrName] = $attrVal wrong";
  11745. }
  11746. } elsif ($attrName eq "gpDef") {
  11747. if (!defined $attrVal){
  11748. } else {
  11749. my @gpDef = split("[ \t][ \t]*", $attrVal);
  11750. my ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax);
  11751. for (my $channel = 0; $channel < @gpDef; $channel ++) {
  11752. my @err;
  11753. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  11754. split(':', $gpDef[$channel]);
  11755. push(@err, "channelName") if (!defined $channelName);
  11756. push(@err, "channelDir") if (!defined($channelDir) || $channelDir !~ m/^O|I$/);
  11757. push(@err, "channelType") if (!defined($channelType) || $channelType !~ m/^\d+$/ || $channelType > 3);
  11758. push(@err, "signalType") if (!defined($signalType) || $signalType !~ m/^\d+$/ || $signalType > 255);
  11759. push(@err, "valueType") if (!defined($valueType) || $valueType !~ m/^\d+$/ || $valueType > 3);
  11760. if ($channelType == 1 || $channelType == 3) {
  11761. push(@err, "resolution") if (!defined($resolution) || $resolution !~ m/^\d+$/ || $resolution > 12);
  11762. }
  11763. if ($channelType == 1) {
  11764. push(@err, "engMin") if (!defined($engMin) || $engMin !~ m/^[+-]?\d+$/ || $engMin < -128 || $engMin > 127);
  11765. push(@err, "scalingMin") if (!defined($scalingMin) || $scalingMin !~ m/^\d+$/ || $scalingMin < 1 || $scalingMin > 13);
  11766. push(@err, "engMax") if (!defined($engMax) || $engMax !~ m/^[+-]?\d+$/ || $engMax < -128 || $engMax > 127);
  11767. push(@err, "scalingMax") if (!defined($scalingMax) || $scalingMax !~ m/^\d+$/ || $scalingMax < 1 || $scalingMax > 13);
  11768. }
  11769. $err = "attribute-value $attrName/channel " . sprintf('%02d', $channel) . ": " .
  11770. join(', ', @err) . " wrong" if (defined $err[0]);
  11771. }
  11772. }
  11773. } elsif ($attrName eq "humidity") {
  11774. if (!defined $attrVal) {
  11775. } elsif ($attrVal =~ m/^\d+$/ && $attrVal >= 0 && $attrVal <= 100) {
  11776. } else {
  11777. #RemoveInternalTimer($hash);
  11778. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11779. }
  11780. } elsif ($attrName =~ m/^key/) {
  11781. if (!defined $attrVal){
  11782. } elsif ($attrVal !~ m/^[\dA-Fa-f]{32}$/) {
  11783. $err = "attribute-value [$attrName] = $attrVal wrong";
  11784. }
  11785. } elsif ($attrName eq "macAlgo") {
  11786. if (!defined $attrVal){
  11787. } elsif ($attrVal !~ m/^no|[3-4]$/) {
  11788. $err = "attribute-value [$attrName] = $attrVal wrong";
  11789. }
  11790. } elsif ($attrName eq "manufID" || $attrName eq "remoteManufID") {
  11791. if (!defined $attrVal){
  11792. } elsif ($attrVal !~ m/^[0-7][\dA-Fa-f]{2}$/) {
  11793. $err = "attribute-value [$attrName] = $attrVal wrong";
  11794. }
  11795. } elsif ($attrName eq "measurementCtrl") {
  11796. if (!defined $attrVal){
  11797. } elsif ($attrVal !~ m/^disable|enable$/) {
  11798. $err = "attribute-value [$attrName] = $attrVal wrong";
  11799. }
  11800. } elsif ($attrName eq "observe") {
  11801. if (!defined $attrVal){
  11802. } elsif (lc($attrVal) !~ m/^(off|on)$/) {
  11803. $err = "attribute-value [$attrName] = $attrVal wrong";
  11804. }
  11805. } elsif ($attrName eq "observeCmdRepetition") {
  11806. if (!defined $attrVal){
  11807. } elsif ($attrVal !~ m/^[1-5]$/) {
  11808. $err = "attribute-value [$attrName] = $attrVal wrong";
  11809. }
  11810. } elsif ($attrName eq "observeErrorAction") {
  11811. if (!defined $attrVal){
  11812. } else {
  11813. my %specials = ("%NAME" => $name,
  11814. "%FAILEDDEV" => '',
  11815. "%TYPE" => '',
  11816. "%EVENT" => ''
  11817. );
  11818. $err = perlSyntaxCheck($attrVal, %specials);
  11819. }
  11820. } elsif ($attrName eq "observeInterval") {
  11821. if (!defined $attrVal){
  11822. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 1) {
  11823. $err = "attribute-value [$attrName] = $attrVal wrong";
  11824. }
  11825. } elsif ($attrName eq "observeLogic") {
  11826. if (!defined $attrVal){
  11827. } elsif (lc($attrVal) !~ m/^and|or$/) {
  11828. $err = "attribute-value [$attrName] = $attrVal wrong";
  11829. }
  11830. } elsif ($attrName eq "pidActorErrorAction") {
  11831. if (!defined $attrVal){
  11832. } elsif ($attrVal !~ m/^errorPos|freeze$/) {
  11833. $err = "attribute-value [$attrName] = $attrVal wrong";
  11834. }
  11835. } elsif ($attrName eq "pidCtrl") {
  11836. if (!defined $attrVal){
  11837. } elsif (lc($attrVal) eq "on") {
  11838. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  11839. } elsif (lc($attrVal) eq "off") {
  11840. EnOcean_setPID(undef, $hash, 'stop', '');
  11841. } else {
  11842. $err = "attribute-value [$attrName] = $attrVal wrong";
  11843. }
  11844. } elsif ($attrName eq "pidActorErrorPos") {
  11845. if (!defined $attrVal) {
  11846. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 0 || $attrVal > 100) {
  11847. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11848. }
  11849. } elsif ($attrName eq "pidDeltaTreshold") {
  11850. my $reFloatpos = '^([\\+]?\\d+\\.?\d*$)';
  11851. if (!defined $attrVal) {
  11852. } elsif ($attrVal !~ m/$reFloatpos/) {
  11853. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11854. }
  11855. } elsif ($attrName eq "pidSensorTimeout") {
  11856. if (!defined $attrVal) {
  11857. } elsif ($attrVal !~ m/^\d+?$/) {
  11858. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11859. }
  11860. } elsif ($attrName =~ m/^pidActorLimitLower|pidActorLimitUpper$/) {
  11861. if (!defined $attrVal) {
  11862. } elsif ($attrVal !~ m/^\d+?$/ || $attrVal < 0 || $attrVal > 100) {
  11863. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11864. }
  11865. } elsif ($attrName =~ m/^pidFactor_.$/) {
  11866. my $reFloatpos = '^([\\+]?\\d+\\.?\d*$)';
  11867. if (!defined $attrVal) {
  11868. } elsif ($attrVal !~ m/$reFloatpos/) {
  11869. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11870. }
  11871. } elsif ($attrName eq "pollInterval") {
  11872. if (!defined $attrVal) {
  11873. } elsif ($attrVal =~ m/^\d+?$/) {
  11874. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  11875. $waitingCmds |= 64;
  11876. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  11877. }
  11878. } else {
  11879. #RemoveInternalTimer($hash);
  11880. $err = "attribute-value [$attrName] = $attrVal is not a integer number or not valid";
  11881. }
  11882. } elsif ($attrName eq "productID") {
  11883. if (!defined $attrVal){
  11884. } elsif ($attrVal !~ m/^[\dA-Fa-f]{8}$/) {
  11885. $err = "attribute-value [$attrName] = $attrVal wrong";
  11886. }
  11887. } elsif ($attrName eq "rampTime") {
  11888. if (!defined $attrVal){
  11889. } elsif ($attrVal =~ m/^\d+?$/) {
  11890. if (AttrVal($name, "subType", "") eq "gateway") {
  11891. if ($attrVal < 0 || $attrVal > 255) {
  11892. $err = "attribute-value [$attrName] = $attrVal wrong";
  11893. }
  11894. } elsif (AttrVal($name, "subType", "") eq "lightCtrl.01") {
  11895. if ($attrVal < 0 || $attrVal > 65535) {
  11896. $err = "attribute-value [$attrName] = $attrVal wrong";
  11897. }
  11898. } else {
  11899. $err = "attribute-value [$attrName] = $attrVal wrong";
  11900. }
  11901. } else {
  11902. $err = "attribute $attrName not supported for subType " . AttrVal($name, "subType", "");
  11903. }
  11904. } elsif ($attrName eq "releasedChannel") {
  11905. if (!defined $attrVal){
  11906. } elsif ($attrVal !~ m/^A|B|C|D|I|0|auto$/) {
  11907. $err = "attribute-value [$attrName] = $attrVal wrong";
  11908. }
  11909. } elsif ($attrName eq "rcvRespAction") {
  11910. if (!defined $attrVal){
  11911. } elsif (AttrVal($name, "subType", "") eq "hvac.01") {
  11912. my %specials = ("%ACTUATORSTATE" => '',
  11913. "%BATTERY" => '',
  11914. "%COVER" => '',
  11915. "%ENERGYINPUT" => '',
  11916. "%ENERGYSTORAGE" => '',
  11917. "%MAINTENANCEMODE" => '',
  11918. "%NAME" => $name,
  11919. "%OPERATIONMODE" => '',
  11920. "%ROOMTEMP" => '',
  11921. "%SELFCTRL" => '',
  11922. "%SETPOINT" => '',
  11923. "%SETPOINTTEMP" => '',
  11924. "%SUMMERMODE" => '',
  11925. "%TEMPERATURE" => '',
  11926. "%WINDOW" => ''
  11927. );
  11928. $err = perlSyntaxCheck($attrVal, %specials);
  11929. } elsif (AttrVal($name, "subType", "") eq "hvac.04") {
  11930. my %specials = ("%BATTERY" => '',
  11931. "%FEEDTEMP" => '',
  11932. "%MAINTENANCEMODE" => '',
  11933. "%NAME" => $name,
  11934. "%OPERATIONMODE" => '',
  11935. "%ROOMTEMP" => '',
  11936. "%SETPOINT" => '',
  11937. "%SETPOINTTEMP" => '',
  11938. "%SUMMERMODE" => '',
  11939. "%TEMPERATURE" => ''
  11940. );
  11941. $err = perlSyntaxCheck($attrVal, %specials);
  11942. }
  11943. } elsif ($attrName eq "remoteID") {
  11944. if (!defined $attrVal){
  11945. # delete old pointer
  11946. delete $modules{EnOcean}{defptr}{$attr{$name}{$attrName}} if (exists($attr{$name}{$attrName}) && $attr{$name}{$attrName} ne $hash->{DEF});
  11947. } elsif ($attrVal =~ m/^[\dA-F]{8}$/) {
  11948. # delete old pointer
  11949. delete $modules{EnOcean}{defptr}{$attr{$name}{$attrName}} if (exists($attr{$name}{$attrName}) && $attr{$name}{$attrName} ne $hash->{DEF});
  11950. $modules{EnOcean}{defptr}{$attrVal} = $hash;
  11951. } else {
  11952. $err = "attribute-value [$attrName] = $attrVal wrong";
  11953. }
  11954. } elsif ($attrName eq "remoteManagement") {
  11955. if (!defined $attrVal){
  11956. } elsif ($attrVal !~ m/^client|manager|off$/) {
  11957. $err = "attribute-value [$attrName] = $attrVal wrong";
  11958. }
  11959. } elsif ($attrName eq "reposition") {
  11960. if (!defined $attrVal){
  11961. } elsif ($attrVal !~ m/^directly|opens|closes$/) {
  11962. $err = "attribute-value [$attrName] = $attrVal wrong";
  11963. }
  11964. } elsif ($attrName =~ m/^rlcRcv|rlcSnd$/) {
  11965. if (!defined $attrVal){
  11966. } elsif (AttrVal($name, "rlcAlgo", "") eq "2++" && $attrVal =~ m/^[\dA-Fa-f]{4}$/) {
  11967. } elsif (AttrVal($name, "rlcAlgo", "") eq "3++" && $attrVal =~ m/^[\dA-Fa-f]{6}$/) {
  11968. } else {
  11969. $err = "attribute-value [$attrName] = $attrVal wrong";
  11970. }
  11971. } elsif ($attrName eq "rlcAlgo") {
  11972. if (!defined $attrVal){
  11973. } elsif ($attrVal !~ m/^no|2++|3++$/) {
  11974. $err = "attribute-value [$attrName] = $attrVal wrong";
  11975. }
  11976. } elsif ($attrName eq "rlcTX") {
  11977. if (!defined $attrVal){
  11978. } elsif (lc($attrVal) !~ m/^true|false$/) {
  11979. $err = "attribute-value [$attrName] = $attrVal wrong";
  11980. }
  11981. } elsif ($attrName eq "rltType") {
  11982. if (!defined $attrVal){
  11983. } elsif ($attrVal !~ m/^1BS|4BS$/) {
  11984. $err = "attribute-value [$attrName] = $attrVal wrong";
  11985. }
  11986. } elsif ($attrName eq "rltRepeat") {
  11987. if (!defined $attrVal){
  11988. } elsif ($attrVal =~ m/^\d+?$/ && $attrVal >= 16 && $attrVal <= 256) {
  11989. } else {
  11990. $err = "attribute-value [$attrName] = $attrVal wrong";
  11991. }
  11992. } elsif ($attrName eq "remoteCode") {
  11993. if (!defined $attrVal){
  11994. } elsif ($attrVal !~ m/^[\dA-Fa-f]{8}$/ || $attrVal eq "00000000" || uc($attrVal) eq "FFFFFFFF") {
  11995. $err = "attribute-value [$attrName] = $attrVal wrong";
  11996. }
  11997. } elsif ($attrName eq "secLevel") {
  11998. if (!defined $attrVal){
  11999. } elsif ($attrVal !~ m/^encapsulation|encryption|off$/) {
  12000. $err = "attribute-value [$attrName] = $attrVal wrong";
  12001. }
  12002. } elsif ($attrName eq "secMode") {
  12003. if (!defined $attrVal){
  12004. } elsif ($attrVal !~ m/^rcv|snd|bidir$/) {
  12005. $err = "attribute-value [$attrName] = $attrVal wrong";
  12006. }
  12007. } elsif ($attrName eq "sendDevStatus") {
  12008. if (!defined $attrVal){
  12009. } elsif ($attrVal !~ m/^no|yes$/) {
  12010. $err = "attribute-value [$attrName] = $attrVal wrong";
  12011. }
  12012. } elsif ($attrName eq "serviceOn") {
  12013. if (!defined $attrVal){
  12014. } elsif ($attrVal !~ m/^(no|yes)$/) {
  12015. $err = "attribute-value [$attrName] = $attrVal wrong";
  12016. }
  12017. } elsif ($attrName eq "setCmdTrigger") {
  12018. if (!defined $attrVal){
  12019. } elsif ($attrVal !~ m/^man|refDev$/) {
  12020. $err = "attribute-value [$attrName] = $attrVal wrong";
  12021. }
  12022. } elsif ($attrName eq "setpointSummerMode") {
  12023. if (!defined $attrVal){
  12024. } elsif ($attrVal !~ m/^\d+$/ && $attrVal >= 0 && $attrVal <= 100) {
  12025. $err = "attribute-value [$attrName] = $attrVal wrong";
  12026. }
  12027. } elsif ($attrName eq "settingAccuracy") {
  12028. if (!defined $attrVal){
  12029. } elsif ($attrVal !~ m/^high|low$/) {
  12030. $err = "attribute-value [$attrName] = $attrVal wrong";
  12031. }
  12032. } elsif ($attrName eq "shutTime") {
  12033. my $data;
  12034. if (!defined $attrVal) {
  12035. if (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  12036. # set shutTime to max
  12037. $data = "7530FF07F5";
  12038. EnOcean_SndRadio(undef, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12039. }
  12040. } elsif (AttrVal($name, "subType", "") =~ m/^blindsCtrl\.0[01]$/) {
  12041. my @attrVal = split(':', $attrVal);
  12042. for (my $channel = 0; $channel <= $#attrVal && $channel < 4; $channel ++) {
  12043. if ($attrVal[$channel] =~ m/^\d+$/ && $attrVal[$channel] >= 5 && $attrVal[$channel] <= 300) {
  12044. $attrVal[$channel] = int($attrVal[$channel] * 100);
  12045. $data = sprintf "%04XFF07%02X", $attrVal[$channel], $channel << 4 | 5;
  12046. EnOcean_SndRadio(0.2 + $channel * 0.5, $hash, 1, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12047. } else {
  12048. $err = "attribute-value [$attrName] = $attrVal wrong";
  12049. }
  12050. }
  12051. } elsif (AttrVal($name, "subType", "") eq "manufProfile" && AttrVal($name, "manufID", "") eq "00D" &&
  12052. $attrVal =~ m/^[+-]?\d+$/ && $attrVal >= 1 && $attrVal <= 255) {
  12053. } else {
  12054. $err = "attribute-value [$attrName] = $attrVal wrong";
  12055. }
  12056. } elsif ($attrName eq "summerMode") {
  12057. if (!defined $attrVal){
  12058. } elsif ($attrVal eq 'on') {
  12059. if (AttrVal($name, 'subType', '') =~ m/^hvac\.0(1|4)$/ && AttrVal($name, 'summerMode', 'off') eq 'off') {
  12060. readingsBeginUpdate($hash);
  12061. readingsBulkUpdate($hash, 'waitingCmds', 'summerMode');
  12062. readingsBulkUpdate($hash, 'operationModeRestore', ReadingsVal($name, 'operationMode', 'setpoint'));
  12063. readingsBulkUpdate($hash, 'setpointTempRestore', ReadingsVal($name, 'setpointTemp', 20));
  12064. readingsBulkUpdate($hash, 'operationMode', 'setpoint');
  12065. readingsEndUpdate($hash, 0);
  12066. } else {
  12067. # attr not changed
  12068. }
  12069. } elsif ($attrVal eq 'off') {
  12070. if (AttrVal($name, 'subType', '') =~ m/^hvac\.0(1|4)$/ && AttrVal($name, 'summerMode', 'off') eq 'on') {
  12071. readingsBeginUpdate($hash);
  12072. readingsBulkUpdate($hash, 'waitingCmds', 'runInit');
  12073. readingsBulkUpdate($hash, 'operationMode', ReadingsVal($name, 'operationModeRestore', 'setpoint'));
  12074. readingsBulkUpdate($hash, 'setpointTemp', ReadingsVal($name, 'setpointTempRestore', 20));
  12075. readingsEndUpdate($hash, 0);
  12076. CommandDeleteReading(undef, "$name .*Restore");
  12077. } else {
  12078. # attr not changed
  12079. }
  12080. } else {
  12081. $err = "attribute-value [$attrName] = $attrVal wrong";
  12082. }
  12083. } elsif ($attrName =~ m/^subDef.?|postmasterID/) {
  12084. if (!defined $attrVal){
  12085. } elsif ($attrVal eq "getNextID") {
  12086. # actions see EnOcean_Notify, global ATTR
  12087. } elsif ($attrVal !~ m/^[\dA-Fa-f]{8}$/) {
  12088. $err = "attribute-value [$attrName] = $attrVal wrong";
  12089. }
  12090. } elsif ($attrName eq "switchHysteresis") {
  12091. if (!defined $attrVal) {
  12092. } elsif ($attrVal =~ m/^\d+(\.\d+)?$/ && $attrVal >= 0.1) {
  12093. } else {
  12094. #RemoveInternalTimer($hash);
  12095. $err = "attribute-value [$attrName] = $attrVal is not a valid number";
  12096. }
  12097. } elsif ($attrName eq "teachMethod") {
  12098. if (!defined $attrVal){
  12099. } elsif ($attrVal !~ m/^1BS|4BS|confirm|GP|RPS|smartAck|STE|UTE$$/) {
  12100. $err = "attribute-value [$attrName] = $attrVal wrong";
  12101. }
  12102. } elsif ($attrName eq "temperatureScale") {
  12103. if (!defined $attrVal){
  12104. } elsif ($attrVal =~ m/^(C|F|default|no_change)$/) {
  12105. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12106. $waitingCmds |= 64;
  12107. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  12108. }
  12109. } else {
  12110. $err = "attribute-value [$attrName] = $attrVal wrong";
  12111. }
  12112. } elsif ($attrName eq "timeNotation") {
  12113. if (!defined $attrVal){
  12114. } elsif ($attrVal =~ m/^(12|24|default|no_change)$/) {
  12115. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12116. $waitingCmds |= 64;
  12117. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  12118. }
  12119. } else {
  12120. $err = "attribute-value [$attrName] = $attrVal wrong";
  12121. }
  12122. } elsif ($attrName =~ m/^timeProgram[1-4]$/) {
  12123. if (!defined $attrVal){
  12124. } 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)$/) {
  12125. if (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12126. # delete remote and send new time program
  12127. delete $hash->{helper}{4}{telegramWait};
  12128. $hash->{helper}{4}{telegramWait}{substr($attrName,-1,1) + 0} = 1;
  12129. for (my $messagePartCntr = 1; $messagePartCntr <= 4; $messagePartCntr ++) {
  12130. if (defined AttrVal($name, "timeProgram" . $messagePartCntr, undef)) {
  12131. $hash->{helper}{4}{telegramWait}{$messagePartCntr} = 1;
  12132. }
  12133. }
  12134. $waitingCmds |= 528;
  12135. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  12136. }
  12137. } else {
  12138. $err = "attribute-value [$attrName] = $attrVal wrong";
  12139. }
  12140. } elsif ($attrName eq "trackerWakeUpCycle") {
  12141. if (!defined $attrVal){
  12142. } elsif ($attrVal !~ m/^10|20|30|40|60|120|180|240|3600|86400$/) {
  12143. $err = "attribute-value [$attrName] = $attrVal wrong";
  12144. }
  12145. } elsif ($attrName eq "updateState") {
  12146. if (!defined $attrVal){
  12147. } elsif ($attrVal !~ m/^default|yes|no$/) {
  12148. $err = "attribute-value [$attrName] = $attrVal wrong";
  12149. }
  12150. } elsif ($attrName eq "uteResponseRequest") {
  12151. if (!defined $attrVal){
  12152. } elsif ($attrVal !~ m/^(yes|no)$/) {
  12153. $err = "attribute-value [$attrName] = $attrVal wrong";
  12154. }
  12155. } elsif ($attrName eq "wakeUpCycle") {
  12156. my $wakeUpCycle = join("|", keys %wakeUpCycle);
  12157. if (!defined $attrVal){
  12158. } elsif ($attrVal =~ m/^$wakeUpCycle$/) {
  12159. if ($attrVal >= 1500 && AttrVal($name, 'wakeUpCycle', 300) < 1500) {
  12160. # switch to summer mode
  12161. $attr{$name}{summerMode} = 'on';
  12162. readingsSingleUpdate($hash, 'waitingCmds', 'summerMode', 0);
  12163. } elsif ($attrVal < 1500 && AttrVal($name, 'wakeUpCycle', 300) >= 1500) {
  12164. # runInit necessary before switch to operation mode
  12165. $attr{$name}{summerMode} = 'off';
  12166. readingsSingleUpdate($hash, 'waitingCmds', 'runInit', 0);
  12167. }
  12168. } else {
  12169. $err = "attribute-value [$attrName] = $attrVal wrong";
  12170. }
  12171. }
  12172. return $err;
  12173. }
  12174. sub EnOcean_Notify(@)
  12175. {
  12176. my ($hash, $dev) = @_;
  12177. my $name = $hash->{NAME};
  12178. my $devName = $dev->{NAME};
  12179. return undef if (AttrVal($name ,"disable", 0) > 0);
  12180. my $max = int(@{$dev->{CHANGED}});
  12181. for (my $i = 0; $i < $max; $i++) {
  12182. my $s = $dev->{CHANGED}[$i];
  12183. $s = "" if(!defined($s));
  12184. if ($devName eq $name) {
  12185. my @parts = split(/: | /, $s);
  12186. #####
  12187. if (exists($hash->{helper}{stopped}) && !$hash->{helper}{stopped} && $parts[0] eq "temperature") {
  12188. # PID regulator: calc gradient for delta as base for d-portion calculation
  12189. my $setpointTemp = ReadingsVal($name, "setpointTemp", undef);
  12190. my $temperature = $parts[1];
  12191. # ---- build difference current - old value
  12192. # calc difference of delta/deltaOld
  12193. my $delta = $setpointTemp - $temperature if (defined($setpointTemp));
  12194. my $deltaOld = ($hash->{helper}{deltaOld} + 0) if (defined($hash->{helper}{deltaOld}));
  12195. my $deltaDiff = ($delta - $deltaOld) if (defined($delta) && defined($deltaOld));
  12196. # ----- build difference of timestamps
  12197. my $deltaOldTsStr = $hash->{helper}{deltaOldTS};
  12198. my $deltaOldTsNum = time_str2num($deltaOldTsStr) if (defined($deltaOldTsStr));
  12199. my $nowTsNum = gettimeofday();
  12200. my $tsDiff = ($nowTsNum - $deltaOldTsNum)
  12201. if (defined($deltaOldTsNum) && (($nowTsNum - $deltaOldTsNum) > 0));
  12202. # ----- calculate gradient of delta
  12203. my $deltaGradient = $deltaDiff / $tsDiff
  12204. if (defined($deltaDiff) && defined($tsDiff) && ($tsDiff > 0 ));
  12205. $deltaGradient = 0 if ( !defined($deltaGradient) );
  12206. # ----- store results
  12207. $hash->{helper}{deltaGradient} = $deltaGradient;
  12208. $hash->{helper}{deltaOld} = $delta;
  12209. $hash->{helper}{deltaOldTS} = TimeNow();
  12210. Log3 $name, 5, "EnOcean $name <notify> $devName $s";
  12211. }
  12212. } elsif ($devName eq "global" && $s =~ m/^RENAMED ([^ ]*) ([^ ]*)$/) {
  12213. if (defined AttrVal($name, "temperatureRefDev", undef)) {
  12214. if (AttrVal($name, "temperatureRefDev", undef) eq $1) {
  12215. CommandAttr(undef, "$name temperatureRefDev $2");
  12216. }
  12217. } elsif (defined AttrVal($name, "setpointRefDev", undef)) {
  12218. if (AttrVal($name, "setpointRefDev", undef) eq $1) {
  12219. CommandAttr(undef, "$name setpointRefDev $2");
  12220. }
  12221. } elsif (defined AttrVal($name, "setpointTempRefDev", undef)) {
  12222. if (AttrVal($name, "setpointTempRefDev", undef) eq $1) {
  12223. CommandAttr(undef, "$name setpointTempRefDev $2");
  12224. }
  12225. } elsif (defined AttrVal($name, "humidityRefDev", undef)) {
  12226. if (AttrVal($name, "humidityRefDev", undef) eq $1) {
  12227. CommandAttr(undef, "$name humidityRefDev $2");
  12228. }
  12229. } elsif (defined AttrVal($name, "observeRefDev", undef)) {
  12230. if (AttrVal($name, "observeRefDev", undef) eq $1) {
  12231. CommandAttr(undef, "$name observeRefDev $2");
  12232. }
  12233. } elsif (defined AttrVal($name, "demandRespRefDev", undef)) {
  12234. if (AttrVal($name, "demandRespRefDev", undef) eq $1) {
  12235. CommandAttr(undef, "$name demandRespRefDev $2");
  12236. }
  12237. }
  12238. #Log3($name, 5, "EnOcean $name <notify> RENAMED old: $1 new: $2");
  12239. } elsif ($devName eq "global" && $s =~ m/^DELETED ([^ ]*)$/) {
  12240. # delete attribute *RefDev
  12241. if (defined AttrVal($name, "temperatureRefDev", undef)) {
  12242. if (AttrVal($name, "temperatureRefDev", undef) eq $1) {
  12243. CommandDeleteAttr(undef, "$name temperatureRefDev");
  12244. }
  12245. } elsif (defined AttrVal($name, "setpointRefDev", undef)) {
  12246. if (AttrVal($name, "setpointRefDev", undef) eq $1) {
  12247. CommandDeleteAttr(undef, "$name setpointRefDev");
  12248. }
  12249. } elsif (defined AttrVal($name, "setpointTempRefDev", undef)) {
  12250. if (AttrVal($name, "setpointTempRefDev", undef) eq $1) {
  12251. CommandDeleteAttr(undef, "$name setpointTempRefDev");
  12252. }
  12253. } elsif (defined AttrVal($name, "humidityRefDev", undef)) {
  12254. if (AttrVal($name, "humidityRefDev", undef) eq $1) {
  12255. CommandDeleteAttr(undef, "$name humidityRefDev");
  12256. }
  12257. } elsif (defined AttrVal($name, "observeRefDev", undef)) {
  12258. if (AttrVal($name, "observeRefDev", undef) eq $1) {
  12259. CommandDeleteAttr(undef, "$name observeRefDev");
  12260. }
  12261. } elsif (defined AttrVal($name, "demandRespRefDev", undef)) {
  12262. if (AttrVal($name, "demandRespRefDev", undef) eq $1) {
  12263. CommandDeleteAttr(undef, "$name demandRespRefDev");
  12264. }
  12265. }
  12266. #Log3($name, 5, "EnOcean $name <notify> DELETED $1");
  12267. } elsif ($devName eq "global" && $s =~ m/^DEFINED ([^ ]*)$/) {
  12268. my $definedName = $1;
  12269. if ($name eq $definedName) {
  12270. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  12271. # control PID regulatior
  12272. if (AttrVal($name, 'pidCtrl', 'on') eq 'on' && ReadingsVal($name, 'maintenanceMode', 'off') eq 'off') {
  12273. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  12274. } else {
  12275. EnOcean_setPID(undef, $hash, 'stop', '');
  12276. }
  12277. }
  12278. }
  12279. # teach-in response actions
  12280. # delete temporary teach-in response device, see V9333_02
  12281. #Log3($name, 2, "EnOcean $name <notify> DEFINED $definedName");
  12282. } elsif ($devName eq "global" && $s =~ m/^INITIALIZED$/) {
  12283. # assign remote management defptr
  12284. if (exists $attr{$name}{remoteID}) {
  12285. $modules{EnOcean}{defptr}{$attr{$name}{remoteID}} = $hash;
  12286. }
  12287. if (AttrVal($name ,"subType", "") eq "roomCtrlPanel.00") {
  12288. CommandDeleteReading(undef, "$name waitingCmds");
  12289. }
  12290. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  12291. # control PID regulatior
  12292. if (AttrVal($name, 'pidCtrl', 'on') eq 'on' && ReadingsVal($name, 'maintenanceMode', 'off') eq 'off') {
  12293. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  12294. } else {
  12295. EnOcean_setPID(undef, $hash, 'stop', '');
  12296. }
  12297. }
  12298. if (exists($attr{$name}{subType}) && $attr{$name}{subType} eq "switch.05") {
  12299. my @getCmd = ($name, 'state');
  12300. EnOcean_Get($hash, @getCmd);
  12301. }
  12302. #Log3($name, 2, "EnOcean $name <notify> INITIALIZED");
  12303. } elsif ($devName eq "global" && $s =~ m/^REREADCFG$/) {
  12304. # assign remote management defptr
  12305. if (exists $attr{$name}{remoteID}) {
  12306. $modules{EnOcean}{defptr}{$attr{$name}{remoteID}} = $hash;
  12307. }
  12308. if (AttrVal($name ,"subType", "") eq "roomCtrlPanel.00") {
  12309. CommandDeleteReading(undef, "$name waitingCmds");
  12310. }
  12311. if (exists($attr{$name}{subType}) && $attr{$name}{subType} =~ m/^hvac\.0(1|4)$/) {
  12312. # control PID regulatior
  12313. if (AttrVal($name, 'pidCtrl', 'on') eq 'on' && ReadingsVal($name, 'maintenanceMode', 'off') eq 'off') {
  12314. EnOcean_setPID(undef, $hash, 'start', ReadingsVal($name, "setpoint", ''));
  12315. } else {
  12316. EnOcean_setPID(undef, $hash, 'stop', '');
  12317. }
  12318. }
  12319. #Log3($name, 2, "EnOcean $name <notify> REREADCFG");
  12320. } elsif ($devName eq "global" && $s =~ m/^ATTR ([^ ]*) ([^ ]*) ([^ ]*)$/) {
  12321. my ($sdev, $attrName, $attrVal) = ($1, $2, $3);
  12322. #Log3 $name, 5, "EnOcean $name <notify> ATTR $1 $2 $3";
  12323. if ($name eq $sdev && $attrName =~ m/^subDef.?/ && $attrVal eq "getNextID") {
  12324. $attr{$name}{$attrName} = '0' x 8;
  12325. $attr{$name}{$attrName} = EnOcean_CheckSenderID("getNextID", $defs{$name}{IODev}{NAME}, "00000000");
  12326. Log3 $name, 2, "EnOcean set $name attribute $attrName to " . $attr{$name}{$attrName};
  12327. } elsif ($attrName eq "devChannel" && $attrVal =~ m/^[\dA-Fa-f]{2}$/) {
  12328. # convert old format
  12329. $attr{$name}{$attrName} = hex $attrVal;
  12330. }
  12331. } elsif ($devName eq "global" && $s =~ m/^DELETEATTR ([^ ]*)$/) {
  12332. #Log3($name, 5, "EnOcean $name <notify> DELETEATTR $1");
  12333. } elsif ($devName eq "global" && $s =~ m/^MODIFIED ([^ ]*)$/) {
  12334. #Log3($name, 5, "EnOcean $name <notify> MODIFIED");
  12335. } elsif ($devName eq "global" && $s =~ m/^SAVE$/) {
  12336. #Log3($name, 5, "EnOcean $name <notify> SAVE");
  12337. } elsif ($devName eq "global" && $s =~ m/^SHUTDOWN$/) {
  12338. #Log3($name, 5, "EnOcean $name <notify> SHUTDOWN");
  12339. } else {
  12340. my @parts = split(/: | /, $s);
  12341. if (defined AttrVal($name, "observeRefDev", undef)) {
  12342. my @observeRefDev = split("[ \t][ \t]*", AttrVal($name, "observeRefDev", undef));
  12343. if (grep /^$devName$/, @observeRefDev) {
  12344. my ($reading, $value) = ("", "");
  12345. $reading = shift @parts;
  12346. if (!defined($parts[0]) || @parts > 1) {
  12347. $value = $s;
  12348. $reading = "state";
  12349. } else {
  12350. $value = $parts[0];
  12351. }
  12352. my @cmdObserve = ($devName, $reading, $value);
  12353. EnOcean_observeParse(2, $hash, @cmdObserve);
  12354. #Log3($name, 5, "EnOcean $name <notify> observeRefDev: $devName $reading: $value");
  12355. }
  12356. }
  12357. if (defined AttrVal($name, "demandRespRefDev", undef)) {
  12358. my @demandRespRefDev = split("[ \t][ \t]*", AttrVal($name, "demandRespRefDev", undef));
  12359. if (grep /^$devName$/, @demandRespRefDev) {
  12360. my @cmdDemandResponse;
  12361. my $actionCmd = AttrVal($name, "demandRespAction", undef);
  12362. if (defined $actionCmd) {
  12363. if ($parts[0] =~ m/^on|off$/) {
  12364. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set $parts[0]");
  12365. my %specials = ("%TARGETNAME" => $name,
  12366. "%NAME" => $devName,
  12367. "%TARGETTYPE" => $hash->{TYPE},
  12368. "%TYPE" => $dev->{TYPE},
  12369. "%LEVEL" => ReadingsVal($devName, "level", 15),
  12370. "%SETPOINT" => ReadingsVal($devName, "setpoint", 255),
  12371. "%POWERUSAGE" => ReadingsVal($devName, "powerUsage", 100),
  12372. "%POWERUSAGESCALE" => ReadingsVal($devName, "powerUsageScale", "max"),
  12373. "%POWERUSAGELEVEL" => ReadingsVal($devName, "powerUsageLevel", "max"),
  12374. "%TARGETSTATE" => ReadingsVal($name, "state", ""),
  12375. "%STATE" => ReadingsVal($devName, "state", "off")
  12376. );
  12377. # action exec
  12378. $actionCmd = EvalSpecials($actionCmd, %specials);
  12379. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  12380. Log3 $name, 2, "EnOcean $name demandRespAction ERROR: $ret" if($ret);
  12381. }
  12382. } elsif (AttrVal($name, "subType", "") =~ m/^switch.*$/ || AttrVal($name, "subTypeSet", "") =~ m/^switch.*$/) {
  12383. if ($parts[0] eq "powerUsageLevel" && $parts[1] eq "max") {
  12384. @cmdDemandResponse = ($name, AttrVal($name, "demandRespMax", "B0"));
  12385. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12386. EnOcean_Set($hash, @cmdDemandResponse);
  12387. } elsif ($parts[0] eq "powerUsageLevel" && $parts[1] eq "min") {
  12388. @cmdDemandResponse = ($name, AttrVal($name, "demandRespMin", "BI"));
  12389. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12390. EnOcean_Set($hash, @cmdDemandResponse);
  12391. }
  12392. } elsif (AttrVal($name, "subType", "") eq "gateway" && AttrVal($name, "gwCmd", "") eq "switching") {
  12393. if ($parts[0] eq "powerUsageLevel" && $parts[1] eq "max") {
  12394. @cmdDemandResponse = ($name, "on");
  12395. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12396. EnOcean_Set($hash, @cmdDemandResponse);
  12397. } elsif ($parts[0] eq "powerUsageLevel" && $parts[1] eq "min") {
  12398. @cmdDemandResponse = ($name, "off");
  12399. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12400. EnOcean_Set($hash, @cmdDemandResponse);
  12401. }
  12402. } elsif ((AttrVal($name, "subType", "") eq "gateway" && AttrVal($name, "gwCmd", "") eq "dimming")
  12403. || AttrVal($name, "subType", "") eq "actuator.01") {
  12404. if ($parts[0] eq "powerUsage") {
  12405. if (ReadingsVal($devName, "powerUsageScale", "max") eq "rel") {
  12406. @cmdDemandResponse = ($name, "dim", $parts[1] * ReadingsVal($name, "dimValueLast", 100) / 100);
  12407. } else {
  12408. @cmdDemandResponse = ($name, "dim", $parts[1]);
  12409. }
  12410. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12411. EnOcean_Set($hash, @cmdDemandResponse);
  12412. }
  12413. } elsif ((AttrVal($name, "subType", "") eq "roomSensorControl.05" && AttrVal($name, "manufID", "") eq "00D")) {
  12414. if ($parts[0] eq "level") {
  12415. @cmdDemandResponse = ($name, "nightReduction", int(5 - 1/3 * $parts[1]));
  12416. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12417. EnOcean_Set($hash, @cmdDemandResponse);
  12418. }
  12419. } elsif (AttrVal($name, "subType", "") eq "lightCtrl.01") {
  12420. if ($parts[0] eq "setpoint") {
  12421. @cmdDemandResponse = ($name, "dim", $parts[1]);
  12422. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12423. EnOcean_Set($hash, @cmdDemandResponse);
  12424. }
  12425. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.01") {
  12426. if ($parts[0] eq "setpoint") {
  12427. @cmdDemandResponse = ($name, "setpoint", $parts[1]);
  12428. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12429. EnOcean_Set($hash, @cmdDemandResponse);
  12430. }
  12431. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.05") {
  12432. if ($parts[0] eq "setpoint") {
  12433. @cmdDemandResponse = ($name, $parts[0], $parts[1]);
  12434. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12435. EnOcean_Set($hash, @cmdDemandResponse);
  12436. }
  12437. } elsif (AttrVal($name, "subType", "") eq "roomCtrlPanel.00") {
  12438. if ($parts[0] eq "powerUsageLevel" && $parts[1] eq "max") {
  12439. @cmdDemandResponse = ($name, "roomCtrlMode", "comfort");
  12440. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12441. EnOcean_Set($hash, @cmdDemandResponse);
  12442. } elsif ($parts[0] eq "powerUsageLevel" && $parts[1] eq "min") {
  12443. @cmdDemandResponse = ($name, "roomCtrlMode", "economy");
  12444. #Log3($name, 3, "EnOcean $name <notify> demandRespRefDev: $devName Cmd: set " . join(" ", @cmdDemandResponse));
  12445. EnOcean_Set($hash, @cmdDemandResponse);
  12446. }
  12447. }
  12448. }
  12449. }
  12450. if (defined(AttrVal($name, "humidityRefDev", undef)) && AttrVal($name, "setCmdTrigger", "man") eq "refDev") {
  12451. if ($devName eq AttrVal($name, "humidityRefDev", "")) {
  12452. if ($parts[0] eq "humidity") {
  12453. if (AttrVal($name, "subType", "") eq "roomSensorControl.01") {
  12454. my @setCmd = ($name, "setpoint");
  12455. EnOcean_Set($hash, @setCmd);
  12456. }
  12457. }
  12458. }
  12459. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12460. }
  12461. if (defined(AttrVal($name, "temperatureRefDev", undef)) && AttrVal($name, "setCmdTrigger", "man") eq "refDev") {
  12462. # sent a setpoint or setpointTemp telegram
  12463. if ($devName eq AttrVal($name, "temperatureRefDev", "")) {
  12464. if ($parts[0] eq "temperature") {
  12465. if (AttrVal($name, "subType", "") eq "roomSensorControl.05" && AttrVal($name, "manufID", "") eq "00D") {
  12466. my @setCmd = ($name, "setpointTemp");
  12467. EnOcean_Set($hash, @setCmd);
  12468. } elsif (AttrVal($name, "subType", "") eq "fanCtrl.00") {
  12469. my @setCmd = ($name, "setpointTemp");
  12470. EnOcean_Set($hash, @setCmd);
  12471. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.01") {
  12472. my @setCmd = ($name, "setpoint");
  12473. EnOcean_Set($hash, @setCmd);
  12474. } elsif (AttrVal($name, "subType", "") eq "roomSensorControl.05") {
  12475. my @setCmd = ($name, "setpoint");
  12476. EnOcean_Set($hash, @setCmd);
  12477. }
  12478. }
  12479. }
  12480. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12481. }
  12482. if (defined(AttrVal($name, "temperatureRefDev", undef)) &&
  12483. $devName eq AttrVal($name, "temperatureRefDev", "") &&
  12484. $parts[0] eq "temperature") {
  12485. if (AttrVal($name, "subType", "") eq "hvac.01") {
  12486. readingsSingleUpdate($hash, "temperature", $parts[1], 1);
  12487. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12488. }
  12489. if (AttrVal($name, "subType", "") eq "hvac.04" && AttrVal($name, "measurementCtrl", "enable") eq 'disable') {
  12490. readingsSingleUpdate($hash, "temperature", $parts[1], 1);
  12491. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12492. }
  12493. }
  12494. if (defined(AttrVal($name, "setpointRefDev", undef)) &&
  12495. $devName eq AttrVal($name, "setpointRefDev", "") &&
  12496. $parts[0] eq "setpoint") {
  12497. if (AttrVal($name, "subType", '') =~ m/^hvac\.0(1|4)$/) {
  12498. my @setCmd = ($name, "setpoint", $parts[1]);
  12499. EnOcean_Set($hash, @setCmd);
  12500. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12501. }
  12502. }
  12503. if (defined(AttrVal($name, "setpointTempRefDev", undef)) &&
  12504. $devName eq AttrVal($name, "setpointTempRefDev", "") &&
  12505. $parts[0] eq "setpointTemp") {
  12506. if (AttrVal($name, "subType", '') =~ m/^hvac\.0(1|4)$/) {
  12507. if (ReadingsVal($name, "setpointTemp", 0) != $parts[1]) {
  12508. my @setCmd = ($name, "setpointTemp", $parts[1]);
  12509. EnOcean_Set($hash, @setCmd);
  12510. #Log3 $name, 2, "EnOcean $name <notify> $devName $s";
  12511. }
  12512. }
  12513. }
  12514. }
  12515. }
  12516. return undef;
  12517. }
  12518. # ADT encapsulation
  12519. sub
  12520. EnOcean_Encapsulation($$$$)
  12521. {
  12522. my ($packetType, $rorg, $data, $destinationID) = @_;
  12523. if ($destinationID eq "FFFFFFFF") {
  12524. return ($rorg, $data);
  12525. } else {
  12526. $data = $rorg . $data;
  12527. return ("A6", $data);
  12528. }
  12529. }
  12530. # set PID regulator
  12531. sub EnOcean_setPID($$$) {
  12532. my ($crtl, $hash, $cmd, $adjust) = @_;
  12533. my $name = $hash->{NAME};
  12534. my ($err, $response, $logLevel) = (undef, 'start', 5);
  12535. @{$hash->{helper}{calcPID}} = (undef, $hash, $cmd);
  12536. if ($cmd eq 'stop' || AttrVal($name, 'pidCtrl', 'on') eq 'off') {
  12537. $hash->{helper}{stopped} = 1;
  12538. readingsSingleUpdate($hash, "pidState", 'stopped', 0);
  12539. RemoveInternalTimer($hash->{helper}{calcPID});
  12540. $response = 'stopped';
  12541. } elsif ($cmd eq 'start' || $cmd eq 'actuator') {
  12542. $hash->{helper}{stopped} = 0;
  12543. $hash->{helper}{adjust} = $adjust;
  12544. RemoveInternalTimer($hash->{helper}{calcPID});
  12545. ($err, $logLevel, $response) = EnOcean_calcPID($hash->{helper}{calcPID});
  12546. }
  12547. return ($err, $logLevel, $response);
  12548. }
  12549. # calc valve setpoint (PID regulator)
  12550. sub EnOcean_calcPID($) {
  12551. my ($pidParam) = @_;
  12552. my ($crtl, $hash, $cmd) = @$pidParam;
  12553. my $name = $hash->{NAME};
  12554. my ($err, $response, $logLevel, $setpoint) = (undef, $cmd, 5, 0);
  12555. #####
  12556. my $reUINT = '^([\\+]?\\d+)$'; # uint without whitespaces
  12557. my $re01 = '^([0,1])$'; # only 0,1
  12558. my $reINT = '^([\\+,\\-]?\\d+$)'; # int
  12559. my $reFloatpos = '^([\\+]?\\d+\\.?\d*$)'; # gleitpunkt positiv float
  12560. my $reFloat = '^([\\+,\\-]?\\d+\\.?\d*$)'; # float
  12561. my $sensor = $name;
  12562. my $reading = 'temperature';
  12563. my $regexp = $reFloat;
  12564. my $DEBUG_Sensor = AttrVal( $name, 'pidDebugSensor', '0' ) eq '1';
  12565. my $DEBUG_Actuation = AttrVal( $name, 'pidDebugActuation', '0' ) eq '1';
  12566. my $DEBUG_Delta = AttrVal( $name, 'pidDebugDelta', '0' ) eq '1';
  12567. my $DEBUG_Calc = AttrVal( $name, 'pidDebugCalc', '0' ) eq '1';
  12568. my $DEBUG_Update = AttrVal( $name, 'pidDebugUpdate', '0' ) eq '1';
  12569. my $DEBUG = $DEBUG_Sensor || $DEBUG_Actuation || $DEBUG_Calc || $DEBUG_Delta || $DEBUG_Update;
  12570. my $actuation = "";
  12571. my $actuationDone = ReadingsVal( $name, 'setpointSet', ReadingsVal( $name, 'setpoint', ""));
  12572. my $actuationCalc = ReadingsVal( $name, 'setpointCalc', "" );
  12573. my $actuationCalcOld = $actuationCalc;
  12574. my $actorTimestamp =
  12575. ( $hash->{helper}{actorTimestamp} )
  12576. ? $hash->{helper}{actorTimestamp}
  12577. : FmtDateTime( gettimeofday() - 3600 * 24 );
  12578. my $desired = '';
  12579. my $sensorStr = ReadingsVal($name, 'temperature',"");
  12580. my $sensorValue = "";
  12581. my $sensorTS = ReadingsTimestamp($name, 'temperature', undef);
  12582. my $sensorIsAlive = 0;
  12583. my $iPortion = ReadingsVal( $name, 'p_i', 0 );
  12584. my $pPortion = ReadingsVal( $name, 'p_p', "" );
  12585. my $dPortion = ReadingsVal( $name, 'p_d', "" );
  12586. my $stateStr = "";
  12587. CommandDeleteReading(undef, "$name pidAlarm");
  12588. my $deltaOld = ReadingsVal( $name, 'delta', 0 );
  12589. my $delta = "";
  12590. my $deltaGradient = ( $hash->{helper}{deltaGradient} ) ? $hash->{helper}{deltaGradient} : 0;
  12591. my $calcReq = 0;
  12592. my $readingUpdateReq = '';
  12593. # ---------------- check conditions
  12594. while (1)
  12595. {
  12596. # --------------- retrive values from attributes
  12597. my $wakeUpCycle = AttrVal($name, 'wakeUpCycle', ReadingsVal($name, 'wakeUpCycle', 300));
  12598. my $pidCycle = $wakeUpCycle / 3;
  12599. $pidCycle = 10 if ($pidCycle < 10);
  12600. $hash->{helper}{actorInterval} = 10;
  12601. $hash->{helper}{actorThreshold} = 0;
  12602. $hash->{helper}{actorKeepAlive} = $pidCycle;
  12603. $hash->{helper}{actorValueDecPlaces} = 0;
  12604. $hash->{helper}{actorErrorAction} = AttrVal($name, 'pidActorErrorAction', 'freeze');
  12605. $hash->{helper}{actorErrorPos} = AttrVal($name, 'pidActorErrorPos', 0);
  12606. $hash->{helper}{calcInterval} = $pidCycle;
  12607. $hash->{helper}{deltaTreshold} = AttrVal($name, 'pidDeltaTreshold', 0);
  12608. if (AttrVal($name, 'measurementCtrl', 'enable') eq 'enable') {
  12609. $hash->{helper}{sensorTimeout} = $wakeUpCycle * 4;
  12610. } else {
  12611. $hash->{helper}{sensorTimeout} = AttrVal($name, 'pidSensorTimeout', 3600);
  12612. }
  12613. $hash->{helper}{reverseAction} = 0;
  12614. $hash->{helper}{updateInterval} = $pidCycle;
  12615. $hash->{helper}{actorLimitLower} = AttrVal($name, 'pidActorLimitLower', 0);
  12616. my $actorLimitLower = $hash->{helper}{actorLimitLower};
  12617. $hash->{helper}{actorLimitUpper} = AttrVal($name, 'pidActorLimitUpper', 100);
  12618. my $actorLimitUpper = $hash->{helper}{actorLimitUpper};
  12619. $hash->{helper}{factor_P} = AttrVal($name, 'pidFactor_P', 25);
  12620. $hash->{helper}{factor_I} = AttrVal($name, 'pidFactor_I', 0.25);
  12621. $hash->{helper}{factor_D} = AttrVal($name, 'pidFactor_D', 0);
  12622. if ($hash->{helper}{stopped}) {
  12623. $stateStr = "stopped";
  12624. last;
  12625. }
  12626. $desired = ReadingsVal( $name, 'setpointTempSet', ReadingsVal($name, 'setpointTemp', ""));
  12627. #my $desired = ReadingsVal( $name, $hash->{helper}{desiredName}, "" );
  12628. # sensor found
  12629. #PID20_Log $hash, 2, "--------------------------" if ($DEBUG);
  12630. #PID20_Log $hash, 2, "S1 sensorStr:$sensorStr sensorTS:$sensorTS" if ($DEBUG_Sensor);
  12631. if ( !$sensorStr && !$stateStr ) {
  12632. $stateStr = "alarm";
  12633. $err = 'no_temperature_value';
  12634. }
  12635. # sensor alive
  12636. if ( $sensorStr && $sensorTS )
  12637. {
  12638. my $timeDiff = EnOcean_TimeDiff($sensorTS);
  12639. $sensorIsAlive = 1 if ( $timeDiff <= $hash->{helper}{sensorTimeout} );
  12640. $sensorStr =~ m/$regexp/;
  12641. $sensorValue = $1;
  12642. $sensorValue = "" if ( !defined($sensorValue) );
  12643. #PID20_Log $hash, 2,
  12644. # "S2 timeOfDay:"
  12645. # . gettimeofday()
  12646. # . " timeDiff:$timeDiff sensorTimeout:"
  12647. # . $hash->{helper}{sensorTimeout}
  12648. # . " --> sensorIsAlive:$sensorIsAlive"
  12649. # if ($DEBUG_Sensor);
  12650. }
  12651. # sensor dead
  12652. if (!$sensorIsAlive && !$stateStr) {
  12653. $stateStr = "alarm";
  12654. $err = 'dead_sensor';
  12655. }
  12656. # missing desired
  12657. if ($desired eq "" && !$stateStr) {
  12658. $stateStr = "alarm";
  12659. $err = 'setpoint_device_missing';
  12660. }
  12661. # check delta threshold
  12662. $delta = ( $desired ne "" && $sensorValue ne "" ) ? $desired - $sensorValue : "";
  12663. $calcReq = 1 if ( !$stateStr && $delta ne "" && ( abs($delta) >= abs( $hash->{helper}{deltaTreshold} ) ) );
  12664. #PID20_Log $hash, 2,
  12665. # "D1 desired[" . ( $desired ne "" ) ? sprintf( "%.1f", $desired )
  12666. # : "" . "] - sensorValue: [" . ( $sensorValue ne "" ) ? sprintf( "%.1f", $sensorValue )
  12667. # : "" . "] = delta[" . ( $delta ne "" ) ? sprintf( "%.2f", $delta )
  12668. # : "" . "] calcReq:$calcReq"
  12669. # if ($DEBUG_Delta);
  12670. #request for calculation
  12671. # ---------------- calculation request
  12672. if ($calcReq)
  12673. {
  12674. # reverse action requested
  12675. my $workDelta = ( $hash->{helper}{reverseAction} == 1 ) ? -$delta : $delta;
  12676. my $deltaOld = -$deltaOld if ( $hash->{helper}{reverseAction} == 1 );
  12677. # calc p-portion
  12678. $pPortion = $workDelta * $hash->{helper}{factor_P};
  12679. # calc d-Portion
  12680. $dPortion = ($deltaGradient) * $hash->{helper}{calcInterval} * $hash->{helper}{factor_D};
  12681. # calc i-portion respecting windUp
  12682. # freeze i-portion if windUp is active
  12683. my $isWindup = $actuationCalcOld
  12684. && ( ( $workDelta > 0 && $actuationCalcOld > $actorLimitUpper )
  12685. || ( $workDelta < 0 && $actuationCalcOld < $actorLimitLower ) );
  12686. if ( $hash->{helper}{adjust} ne "" )
  12687. {
  12688. $iPortion = $hash->{helper}{adjust} - ( $pPortion + $dPortion );
  12689. $iPortion = $actorLimitUpper if ( $iPortion > $actorLimitUpper );
  12690. $iPortion = $actorLimitLower if ( $iPortion < $actorLimitLower );
  12691. #PID20_Log $hash, 5, "adjust request with:" . $hash->{helper}{adjust} . " ==> p_i:$iPortion";
  12692. $hash->{helper}{adjust} = "";
  12693. } elsif ( !$isWindup ) # integrate only if no windUp
  12694. {
  12695. # normalize the intervall to minute=60 seconds
  12696. $iPortion = $iPortion + $workDelta * $hash->{helper}{factor_I} * $hash->{helper}{calcInterval} / 60;
  12697. $hash->{helper}{isWindUP} = 0;
  12698. }
  12699. $hash->{helper}{isWindUP} = $isWindup;
  12700. # check callback for iPortion
  12701. my $iportionCallBeforeSetting = AttrVal( $name, 'pidIPortionCallBeforeSetting', undef );
  12702. if ( defined($iportionCallBeforeSetting) && exists &$iportionCallBeforeSetting )
  12703. {
  12704. #PID20_Log $hash, 5, 'start callback ' . $iportionCallBeforeSetting . ' with iPortion:' . $iPortion;
  12705. no strict "refs";
  12706. $iPortion = &$iportionCallBeforeSetting( $name, $iPortion );
  12707. use strict "refs";
  12708. #PID20_Log $hash, 5, 'return value of ' . $iportionCallBeforeSetting . ':' . $iPortion;
  12709. }
  12710. # calc actuation
  12711. $actuationCalc = $pPortion + $iPortion + $dPortion;
  12712. #PID20_Log $hash, 2, "P1 delta:" . sprintf( "%.2f", $delta ) . " isWindup:$isWindup" if ($DEBUG_Calc);
  12713. #PID20_Log $hash, 2,
  12714. # "P2 pPortion:"
  12715. # . sprintf( "%.2f", $pPortion )
  12716. # . " iPortion:"
  12717. # . sprintf( "%.2f", $iPortion )
  12718. # . " dPortion:"
  12719. # . sprintf( "%.2f", $dPortion )
  12720. # . " actuationCalc:"
  12721. # . sprintf( "%.2f", $actuationCalc )
  12722. # if ($DEBUG_Calc);
  12723. }
  12724. $readingUpdateReq = 1; # in each case update readings
  12725. # ---------------- acutation request
  12726. my $noTrouble = ( $desired ne "" && $sensorIsAlive );
  12727. # check actor fallback in case of sensor fault
  12728. if (!$sensorIsAlive && ($hash->{helper}{actorErrorAction} eq "errorPos")) {
  12729. #$stateStr .= "- force pid-output to errorPos";
  12730. $err .= ':actuator_in_errorPos';
  12731. $actuationCalc = $hash->{helper}{actorErrorPos};
  12732. $actuationCalc = "" if ( !defined($actuationCalc) );
  12733. }
  12734. # check acutation diff
  12735. $actuation = $actuationCalc;
  12736. # limit $actuation
  12737. $actuation = $actorLimitUpper if ( $actuation ne "" && ( $actuation > $actorLimitUpper ) );
  12738. $actuation = $actorLimitLower if ( $actuation ne "" && ( $actuation < $actorLimitLower ) );
  12739. # check if round request
  12740. my $fmt = "%." . $hash->{helper}{actorValueDecPlaces} . "f";
  12741. $actuation = sprintf( $fmt, $actuation ) if ( $actuation ne "" );
  12742. my $actuationDiff = abs( $actuation - $actuationDone )
  12743. if ( $actuation ne "" && $actuationDone ne "" );
  12744. #PID20_Log $hash, 2,
  12745. # "A1 act:$actuation actDone:$actuationDone "
  12746. # . " actThreshold:"
  12747. # . $hash->{helper}{actorThreshold}
  12748. # . " actDiff:$actuationDiff"
  12749. # if ($DEBUG_Actuation);
  12750. # check threshold-condition for actuation
  12751. my $rsTS = $actuationDone ne "" && $actuationDiff >= $hash->{helper}{actorThreshold};
  12752. # ...... special handling if acutation is in the black zone between actorLimit and (actorLimit - actorThreshold)
  12753. # upper range
  12754. my $rsUp =
  12755. $actuationDone ne ""
  12756. && $actuation > $actorLimitUpper - $hash->{helper}{actorThreshold}
  12757. && $actuationDiff != 0
  12758. && $actuation >= $actorLimitUpper;
  12759. # low range
  12760. my $rsDown =
  12761. $actuationDone ne ""
  12762. && $actuation < $actorLimitLower + $hash->{helper}{actorThreshold}
  12763. && $actuationDiff != 0
  12764. && $actuation <= $actorLimitLower;
  12765. # upper or lower limit are exceeded
  12766. my $rsLimit = $actuationDone ne "" && ( $actuationDone < $actorLimitLower || $actuationDone > $actorLimitUpper );
  12767. my $actuationByThreshold = ( ( $rsTS || $rsUp || $rsDown ) && $noTrouble );
  12768. #PID20_Log $hash, 2, "A2 rsTS:$rsTS rsUp:$rsUp rsDown:$rsDown noTrouble:$noTrouble"
  12769. # if ($DEBUG_Actuation);
  12770. # check time condition for actuation
  12771. my $actTimeDiff = EnOcean_TimeDiff($actorTimestamp); # $actorTimestamp is valid in each case
  12772. my $actuationByTime = ($noTrouble) && ( $actTimeDiff > $hash->{helper}{actorInterval} );
  12773. #PID20_Log $hash, 2,
  12774. # "A3 actTS:$actorTimestamp"
  12775. # . " actTimeDiff:"
  12776. # . sprintf( "%.2f", $actTimeDiff )
  12777. # . " actInterval:"
  12778. # . $hash->{helper}{actorInterval}
  12779. # . "-->actByTime:$actuationByTime "
  12780. # if ($DEBUG_Actuation);
  12781. # check keep alive condition for actuation
  12782. my $actuationKeepAliveReq = ( $actTimeDiff >= $hash->{helper}{actorKeepAlive} )
  12783. if ( defined($actTimeDiff) && $actuation ne "" );
  12784. # build total actuation request
  12785. my $actuationReq = (
  12786. ( $actuationByThreshold && $actuationByTime )
  12787. || $actuationKeepAliveReq # request by keep alive
  12788. || $rsLimit # upper or lower limit are exceeded
  12789. || $actuationDone eq "" # startup condition
  12790. ) && $actuation ne ""; # acutation is initialized
  12791. #PID20_Log $hash, 2,
  12792. # "A4 (actByTh:$actuationByThreshold && actByTime:$actuationByTime)"
  12793. # . "||actKeepAlive:$actuationKeepAliveReq"
  12794. # . "||rsLimit:$rsLimit=actnReq:$actuationReq"
  12795. # if ($DEBUG_Actuation);
  12796. # ................ perform output to actor
  12797. if ($actuationReq)
  12798. {
  12799. $readingUpdateReq = 1; # update the readings
  12800. # check calback for actuation
  12801. my $actorCallBeforeSetting = AttrVal( $name, 'pidActorCallBeforeSetting', undef );
  12802. if ( defined($actorCallBeforeSetting) && exists &$actorCallBeforeSetting )
  12803. {
  12804. #PID20_Log $hash, 5, 'start callback ' . $actorCallBeforeSetting . ' with actuation:' . $actuation;
  12805. no strict "refs";
  12806. $actuation = &$actorCallBeforeSetting( $name, $actuation );
  12807. use strict "refs";
  12808. #PID20_Log $hash, 5, 'return value of ' . $actorCallBeforeSetting . ':' . $actuation;
  12809. }
  12810. #build command for fhem
  12811. #PID20_Log $hash, 5,
  12812. # "actor:"
  12813. # . $hash->{helper}{actor}
  12814. # . " actorCommand:"
  12815. # . $hash->{helper}{actorCommand}
  12816. # . " actuation:"
  12817. # . $actuation;
  12818. #my $cmd = sprintf( "set %s %s %g", $hash->{helper}{actor}, $hash->{helper}{actorCommand}, $actuation );
  12819. # execute command
  12820. my $ret;
  12821. #$ret = fhem $cmd;
  12822. $setpoint = $actuation;
  12823. $actuationDone = $actuation;
  12824. # note timestamp
  12825. $hash->{helper}{actorTimestamp} = TimeNow();
  12826. my $retStr = "";
  12827. $retStr = " with return-value:" . $ret if ( defined($ret) && ( $ret ne '' ) );
  12828. #PID20_Log $hash, 3, "<$cmd> " . $retStr;
  12829. }
  12830. my $updateAlive = ( $actuation ne "" )
  12831. && EnOcean_TimeDiff( ReadingsTimestamp( $name, 'setpointSet', gettimeofday() ) ) >= $hash->{helper}{updateInterval};
  12832. # my $updateReq = ( ( $actuationReq || $updateAlive ) && $actuation ne "" );
  12833. # PID20_Log $hash, 2, "U1 actReq:$actuationReq updateAlive:$updateAlive --> updateReq:$updateReq" if ($DEBUG_Update);
  12834. # ---------------- update request
  12835. if ($readingUpdateReq)
  12836. {
  12837. readingsBeginUpdate($hash);
  12838. #readingsBulkUpdate( $hash, $hash->{helper}{desiredName}, $desired ) if ( $desired ne "" );
  12839. #readingsBulkUpdate( $hash, $hash->{helper}{measuredName}, $sensorValue ) if ( $sensorValue ne "" );
  12840. readingsBulkUpdate( $hash, 'p_p', $pPortion ) if ( $pPortion ne "" );
  12841. readingsBulkUpdate( $hash, 'p_d', $dPortion ) if ( $dPortion ne "" );
  12842. readingsBulkUpdate( $hash, 'p_i', $iPortion ) if ( $iPortion ne "" );
  12843. readingsBulkUpdate( $hash, 'setpointSet', $actuationDone) if ($actuationDone ne "");
  12844. readingsBulkUpdate( $hash, 'setpointCalc', $actuationCalc ) if ( $actuationCalc ne "" );
  12845. readingsBulkUpdate( $hash, 'delta', $delta ) if ( $delta ne "" );
  12846. readingsEndUpdate( $hash, 1 );
  12847. #PID20_Log $hash, 5, "readings updated";
  12848. }
  12849. last;
  12850. } # end while
  12851. # ........ update statePID.
  12852. $stateStr = 'idle' if ($stateStr eq '' && !$calcReq);
  12853. $stateStr = 'processing' if ($stateStr eq '' && $calcReq);
  12854. #PID20_Log $hash, 2, "C1 stateStr:$stateStr calcReq:$calcReq" if ($DEBUG_Calc);
  12855. #......... timer setup
  12856. #my $next = gettimeofday() + $hash->{helper}{calcInterval};
  12857. #RemoveInternalTimer($name); # prevent multiple timers for same hash
  12858. #InternalTimer( $next, "PID20_Calc", $name, 1 );
  12859. #PID20_Log $hash, 2, "InternalTimer next:".FmtDateTime($next)." PID20_Calc name:$name DEBUG_Calc:$DEBUG_Calc";
  12860. readingsBeginUpdate($hash);
  12861. readingsBulkUpdate($hash, 'pidState', $stateStr);
  12862. readingsBulkUpdate($hash, 'pidAlarm', $err) if (defined $err);
  12863. readingsEndUpdate($hash, 1);
  12864. Log3($name, 5, "EnOcean $name EnOcean_calcPID Cmd: $cmd pidState: $stateStr T: $sensorValue SP: $setpoint SPT: $desired");
  12865. @{$hash->{helper}{calcPID}} = (undef, $hash, 'periodic');
  12866. RemoveInternalTimer($hash->{helper}{calcPID});
  12867. InternalTimer(gettimeofday() + $hash->{helper}{calcInterval} * 1.02, "EnOcean_calcPID", $hash->{helper}{calcPID}, 0);
  12868. return ($err, $logLevel, $response);
  12869. }
  12870. # sent message to Multisnesor Window Handle (EEP D2-06-01)
  12871. sub
  12872. EnOcean_multisensor_01Snd($$$)
  12873. {
  12874. my ($crtl, $hash, $packetType) = @_;
  12875. my $name = $hash->{NAME};
  12876. my ($data, $err, $response, $logLevel);
  12877. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12878. return ($err, $response);
  12879. }
  12880. # sent message to Room Control Panel (EEP D2-10-xx)
  12881. sub
  12882. EnOcean_roomCtrlPanel_00Snd($$$$$$$$)
  12883. {
  12884. my ($crtl, $hash, $packetType, $mid, $mcf, $irc, $fbc, $gmt) = @_;
  12885. my $name = $hash->{NAME};
  12886. my ($data, $err, $response, $logLevel);
  12887. my $messagePart = 1;
  12888. if ($mid == 0) {
  12889. # general massage
  12890. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  12891. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12892. if ($err) {
  12893. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  12894. } else {
  12895. Log3 $name, $logLevel, "EnOcean $name $response";
  12896. }
  12897. if (!defined($irc)) {
  12898. } elsif ($irc == 0) {
  12899. # acknowledge request
  12900. } elsif ($irc == 1) {
  12901. # data request
  12902. } elsif ($irc == 2) {
  12903. # configuration request
  12904. } elsif ($irc == 3) {
  12905. # room control request
  12906. } elsif ($irc == 4) {
  12907. # time program request
  12908. }
  12909. if (!defined($fbc)) {
  12910. } elsif ($fbc == 0) {
  12911. # acknowledge / heartbeat
  12912. } elsif ($fbc == 1) {
  12913. # telegram repetition request
  12914. } elsif ($fbc == 2) {
  12915. # message repetition request
  12916. } elsif ($fbc == 3) {
  12917. # reserved
  12918. }
  12919. if (!defined($gmt)) {
  12920. } elsif ($gmt == 0) {
  12921. # information request
  12922. } elsif ($gmt == 1) {
  12923. # feetback
  12924. }
  12925. } elsif ($mid == 1) {
  12926. # data message
  12927. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  12928. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12929. if ($err) {
  12930. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  12931. } else {
  12932. Log3 $name, $logLevel, "EnOcean $name $response";
  12933. }
  12934. } elsif ($mid == 2) {
  12935. # configuration message
  12936. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  12937. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12938. if ($err) {
  12939. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  12940. } else {
  12941. Log3 $name, $logLevel, "EnOcean $name $response";
  12942. }
  12943. } elsif ($mid == 3) {
  12944. # room control setup
  12945. ($err, $response, $data, $logLevel) = EnOcean_roomCtrlPanel_00Cmd(undef, $hash, $mcf, $messagePart);
  12946. EnOcean_SndRadio(undef, $hash, $packetType, "D2", $data, AttrVal($name, "subDef", "00000000"), "00", $hash->{DEF});
  12947. if ($err) {
  12948. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  12949. } else {
  12950. Log3 $name, $logLevel, "EnOcean $name $response";
  12951. }
  12952. } elsif ($mid == 4) {
  12953. # time program setup
  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. }
  12962. return ($err, $response);
  12963. }
  12964. # generate command to Room Control Panel (EEP D2-10-xx)
  12965. sub
  12966. EnOcean_roomCtrlPanel_00Cmd($$$$)
  12967. {
  12968. my ($crtl, $hash, $mcf, $messagePart) = @_;
  12969. my $name = $hash->{NAME};
  12970. my $data = "0000";
  12971. my $err;
  12972. my $response = "acknowledge send";
  12973. my $logLevel = 4;
  12974. # Waitings Commands (waitingCmds)
  12975. # 1 = sent data request
  12976. # 2 = sent data message
  12977. # 4 = sent configuration message (time)
  12978. # 8 = sent room control setup
  12979. # 16 = sent time program setup
  12980. # 32 = sent configuration request
  12981. # 64 = sent configuration message
  12982. # 128 = sent room control setup request
  12983. # 256 = sent time program request
  12984. # 512 = sent delete time program
  12985. my $waitingCmds = ReadingsVal($name, "waitingCmds", 0);
  12986. if ($mcf == 0) {
  12987. # message complete
  12988. if ($waitingCmds & 8) {
  12989. # room control setup waiting
  12990. my ($db5, $db4, $db3, $db2, $db1, $db0) = (96, 0, 0, 0, 0, 0, 0);
  12991. if (defined ReadingsVal($name, "setpointComfortTempSet", undef)) {
  12992. $db1 = ReadingsVal($name, "setpointComfortTempSet", 0) * 255 / 40;
  12993. $db0 = $db0 | 1;
  12994. CommandDeleteReading(undef, "$name setpointComfortTempSet");
  12995. }
  12996. if (defined ReadingsVal($name, "setpointEconomyTempSet", undef)) {
  12997. $db2 = ReadingsVal($name, "setpointEconomyTempSet", 0) * 255 / 40;
  12998. $db0 = $db0 | 2;
  12999. CommandDeleteReading(undef, "$name setpointEconomyTempSet");
  13000. }
  13001. if (defined ReadingsVal($name, "setpointPreComfortTempSet", undef)) {
  13002. $db3 = ReadingsVal($name, "setpointPreComfortTempSet", 0) * 255 / 40;
  13003. $db0 = $db0 | 4;
  13004. CommandDeleteReading(undef, "$name setpointPreComfortTempSet");
  13005. }
  13006. if (defined ReadingsVal($name, "setpointBuildingProtectionTempSet", undef)) {
  13007. $db4 = ReadingsVal($name, "setpointBuildingProtectionTempSet", 0) * 255 / 40;
  13008. $db0 = $db0 | 8;
  13009. CommandDeleteReading(undef, "$name setpointBuildingProtectionTempSet");
  13010. }
  13011. $data = sprintf "%02X%02X%02X%02X%02X%02X", $db5, $db4, $db3, $db2, $db1, $db0;
  13012. # clear command
  13013. $waitingCmds = $waitingCmds & 247 + 0xFF00;
  13014. $response = "room control setup send $data";
  13015. $logLevel = 2;
  13016. } elsif ($waitingCmds & 64 || $waitingCmds & 4) {
  13017. # configuration message waiting
  13018. my ($sec, $min, $hour, $day, $month, $year) = localtime();
  13019. my ($key, $val);
  13020. $month += 1;
  13021. $year += 1900;
  13022. my ($db7, $db6, $db5, $db4, $db1, $db0) = (64, 0, 0, 0, $min << 2, $hour << 3);
  13023. $db6 |= 1 if (AttrVal($name, "blockFanSpeed", "no") ne "yes" );
  13024. $db6 |= 2 if (AttrVal($name, "blockSetpointTemp", "no") ne "yes" );
  13025. $db6 |= 4 if (AttrVal($name, "blockOccupancy", "no") ne "yes" );
  13026. $db6 |= 8 if (AttrVal($name, "blockTimeProgram", "no") ne "yes" );
  13027. $db6 |= 16 if (AttrVal($name, "blockDateTime", "no") ne "yes" );
  13028. $db6 |= 32 if (AttrVal($name, "blockDisplay", "no") ne "yes" );
  13029. $db6 |= 64 if (AttrVal($name, "blockTemp", "no") ne "yes" );
  13030. $db6 |= 128 if (AttrVal($name, "blockMotion", "no") ne "yes" );
  13031. $db5 = AttrVal($name, "pollInterval", 10);
  13032. if ($db5 > 60 && $db5 <= 180) {
  13033. $db5 = 61;
  13034. } elsif ($db5 > 180 && $db5 <= 720) {
  13035. $db5 = 62;
  13036. } elsif ($db5 > 720) {
  13037. $db5 = 63;
  13038. }
  13039. $db5 = $db5 << 2;
  13040. $db5 |= 2 if (AttrVal($name, "blockKey", "no") ne "yes" );
  13041. my $displayContent = AttrVal($name, "displayContent", "no_change");
  13042. my $displayContentVal = 0;
  13043. my %displayContent = ("humidity" => 7,
  13044. "off" => 6,
  13045. "setpointTemp" => 5,
  13046. "tempertureExtern" => 4,
  13047. "temperatureIntern" => 3,
  13048. "time" => 2,
  13049. "default" => 1,
  13050. "no_change" => 0
  13051. );
  13052. while (($key, $val) = each(%displayContent)) {
  13053. $displayContentVal = $val if ($key eq $displayContent);
  13054. }
  13055. my $temperatureScale = AttrVal($name, "temperatureScale", "no_change");
  13056. my $temperatureScaleVal = 0;
  13057. my %temperatureScale = ("F" => 3,
  13058. "C" => 2,
  13059. "default" => 1,
  13060. "no_change" => 0
  13061. );
  13062. while (($key, $val) = each(%temperatureScale)) {
  13063. $temperatureScaleVal = $val if ($key eq $temperatureScale);
  13064. }
  13065. my $daylightSavingTimeVal = 0;
  13066. $daylightSavingTimeVal = 1 if (AttrVal($name, "daylightSavingTime", "supported") eq "not_supported");
  13067. my $timeNotation = AttrVal($name, "timeNotation", "no_change");
  13068. my $timeNotationVal = 0;
  13069. if ($timeNotation eq "no_change") {
  13070. $timeNotationVal = 0;
  13071. } elsif ($timeNotation eq "default") {
  13072. $timeNotationVal = 1;
  13073. } elsif ($timeNotation == 24) {
  13074. $timeNotationVal = 2;
  13075. } elsif ($timeNotation == 12) {
  13076. $timeNotationVal = 3;
  13077. }
  13078. $db4 = (($displayContentVal << 2 | $temperatureScaleVal) << 1 | $daylightSavingTimeVal) << 2 | $timeNotationVal;
  13079. my $db32 = ($day << 4 | $month) << 7 | $year - 2000;
  13080. if ($waitingCmds & 4) {
  13081. $db0 |= 1;
  13082. # clear time command
  13083. $waitingCmds &= 251 + 0xFF00;
  13084. }
  13085. if ($waitingCmds & 64) {
  13086. # clear config command
  13087. $waitingCmds &= 191 + 0xFF00;
  13088. }
  13089. $data = sprintf "%02X%02X%02X%02X%04X%02X%02X", $db7, $db6, $db5, $db4, $db32, $db1, $db0;
  13090. $response = "configuration message send $data";
  13091. $logLevel = 2;
  13092. } elsif ($waitingCmds & 2) {
  13093. # data message waiting
  13094. my ($db7, $db6, $db5, $db4, $db3, $db2, $db1, $db0) = (32, 0, 0, 0, 0, 0, 0, 0, 0);
  13095. if (defined ReadingsVal($name, "setpointTempSet", undef)) {
  13096. $db1 = ReadingsVal($name, "setpointTempSet", 0) * 255 / 40;
  13097. $db2 |= 2;
  13098. CommandDeleteReading(undef, "$name setpointTempSet");
  13099. }
  13100. my $heatingSet;
  13101. if (defined ReadingsVal($name, "heatingSet", undef)) {
  13102. $heatingSet = ReadingsVal($name, "heatingSet", 0);
  13103. } else {
  13104. $heatingSet = ReadingsVal($name, "heating", 0);
  13105. }
  13106. if ($heatingSet eq "no_change") {
  13107. $heatingSet = 0;
  13108. } elsif ($heatingSet eq "on") {
  13109. $heatingSet = 1;
  13110. } elsif ($heatingSet eq "off") {
  13111. $heatingSet = 2;
  13112. } elsif ($heatingSet eq "auto") {
  13113. $heatingSet = 3;
  13114. }
  13115. $db2 |= $heatingSet << 4;
  13116. CommandDeleteReading(undef, "$name heatingSet");
  13117. my $coolingSet;
  13118. if (defined ReadingsVal($name, "coolingSet", undef)) {
  13119. $coolingSet = ReadingsVal($name, "coolingSet", 0);
  13120. } else {
  13121. $coolingSet = ReadingsVal($name, "cooling", 0);
  13122. }
  13123. if ($coolingSet eq "no_change") {
  13124. $coolingSet = 0;
  13125. } elsif ($coolingSet eq "on") {
  13126. $coolingSet = 1;
  13127. } elsif ($coolingSet eq "off") {
  13128. $coolingSet = 2;
  13129. } elsif ($coolingSet eq "auto") {
  13130. $coolingSet = 3;
  13131. }
  13132. $db2 |= $coolingSet << 6;
  13133. CommandDeleteReading(undef, "$name coolingSet");
  13134. my $roomCtrlModeSet;
  13135. if (defined ReadingsVal($name, "roomCtrlModeSet", undef)) {
  13136. $roomCtrlModeSet = ReadingsVal($name, "roomCtrlModeSet", 0);
  13137. } else {
  13138. $roomCtrlModeSet = ReadingsVal($name, "roomCtrlMode", 0);
  13139. }
  13140. if ($roomCtrlModeSet eq "comfort") {
  13141. $roomCtrlModeSet = 0;
  13142. } elsif ($roomCtrlModeSet eq "economy") {
  13143. $roomCtrlModeSet = 1;
  13144. } elsif ($roomCtrlModeSet eq "preComfort") {
  13145. $roomCtrlModeSet = 2;
  13146. } elsif ($roomCtrlModeSet eq "buildingProtection") {
  13147. $roomCtrlModeSet = 3;
  13148. }
  13149. $db2 |= $roomCtrlModeSet << 2;
  13150. CommandDeleteReading(undef, "$name roomCtrlModeSet");
  13151. my $windowSet;
  13152. if (defined ReadingsVal($name, "windowSet", undef)) {
  13153. $windowSet = ReadingsVal($name, "windowSet", 0);
  13154. } else {
  13155. $windowSet = ReadingsVal($name, "window", 0);
  13156. }
  13157. if ($windowSet eq "no_change") {
  13158. $windowSet = 0;
  13159. } elsif ($windowSet eq "closed") {
  13160. $windowSet = 1;
  13161. } elsif ($windowSet eq "open") {
  13162. $windowSet = 2;
  13163. } elsif ($windowSet eq "reserved") {
  13164. $windowSet = 3;
  13165. }
  13166. $db4 |= $windowSet;
  13167. CommandDeleteReading(undef, "$name windowSet");
  13168. my $fanSpeedModeSet;
  13169. if (defined ReadingsVal($name, "fanSpeedModeSet", undef)) {
  13170. $fanSpeedModeSet = ReadingsVal($name, "fanSpeedModeSet", 0);
  13171. } else {
  13172. $fanSpeedModeSet = ReadingsVal($name, "fanSpeedMode", 0);
  13173. }
  13174. $db4 |= 64 if ($fanSpeedModeSet eq "local");
  13175. CommandDeleteReading(undef, "$name fanSpeedModeSet");
  13176. if (defined ReadingsVal($name, "fanSpeedSet", undef)) {
  13177. $db5 = ReadingsVal($name, "fanSpeedSet", 0);
  13178. $db4 |= 128;
  13179. CommandDeleteReading(undef, "$name fanSpeedSet");
  13180. }
  13181. $data = sprintf "%02X%02X%02X%02X%02X%02X%02X%02X", $db7, $db6, $db5, $db4, $db3, $db2, $db1, $db0;
  13182. # clear command
  13183. $waitingCmds = $waitingCmds & 253 + 0xFF00;
  13184. $response = "data message send";
  13185. $logLevel = 2;
  13186. } elsif ($waitingCmds & 512) {
  13187. # delete time program command waiting
  13188. $data = "800000000001";
  13189. # clear command
  13190. $waitingCmds = $waitingCmds & 0xFDFF;
  13191. $response = "delete time program send";
  13192. $logLevel = 2;
  13193. } elsif ($waitingCmds & 16) {
  13194. # time program setup waiting
  13195. my ($db5, $endMinute, $endHour, $startMinute, $startHour, $db0) = (128, 0, 0, 0, 0, 0, 0);
  13196. my ($key, $val);
  13197. my $messagePartCntr;
  13198. for ($messagePartCntr = 4; $messagePartCntr >= 1; $messagePartCntr --) {
  13199. if ($hash->{helper}{4}{telegramWait}{$messagePartCntr}) {
  13200. $hash->{helper}{4}{telegramWait}{$messagePartCntr} = 0;
  13201. my $timeProgram = AttrVal($name, "timeProgram" . $messagePartCntr, undef);
  13202. my @timeProgram = split("[ \t][ \t]*", $timeProgram);
  13203. my ($period, $roomCtrlMode) = ($timeProgram[0], $timeProgram[3]);
  13204. ($startHour, $startMinute) = split(':', $timeProgram[1]);
  13205. ($endHour, $endMinute) = split(':', $timeProgram[2]);
  13206. my $periodVal = 0;
  13207. my %period = ("FrMo" => 15,
  13208. "FrSu" => 14,
  13209. "ThFr" => 13,
  13210. "WeFr" => 12,
  13211. "TuTh" => 11,
  13212. "MoWe" => 10,
  13213. "Su" => 9,
  13214. "Sa" => 8,
  13215. "Fr" => 7,
  13216. "Th" => 6,
  13217. "We" => 5,
  13218. "Tu" => 4,
  13219. "Mo" => 3,
  13220. "SaSu" => 2,
  13221. "MoFr" => 1,
  13222. "MoSu" => 0
  13223. );
  13224. while (($key, $val) = each(%period)) {
  13225. $periodVal = $val if ($key eq $period);
  13226. }
  13227. if ($roomCtrlMode eq "buildingProtection") {
  13228. $roomCtrlMode = 3;
  13229. } elsif ($roomCtrlMode eq "preComfort") {
  13230. $roomCtrlMode = 2;
  13231. } elsif ($roomCtrlMode eq "economy") {
  13232. $roomCtrlMode = 1;
  13233. } else{
  13234. $roomCtrlMode = 0;
  13235. }
  13236. if ($messagePartCntr > 1) {
  13237. # set mcf flag
  13238. $db5 |= 1;
  13239. } else {
  13240. # clear command
  13241. $waitingCmds = $waitingCmds & 239 + 0xFF00;
  13242. }
  13243. $data = sprintf "%02X%02X%02X%02X%02X%02X", $db5, $endMinute, $endHour, $startMinute, $startHour, $periodVal << 4 | $roomCtrlMode << 2;
  13244. $response = "time program setup send";
  13245. $logLevel = 2;
  13246. last;
  13247. }
  13248. }
  13249. } elsif ($waitingCmds & 1) {
  13250. # data request waiting
  13251. $data = "0009";
  13252. # clear command
  13253. $waitingCmds = $waitingCmds & 254 + 0xFF00;
  13254. $response = "data request send";
  13255. $logLevel = 2;
  13256. } elsif ($waitingCmds & 32) {
  13257. # configuration request waiting
  13258. $data = "0011";
  13259. # clear command
  13260. $waitingCmds = $waitingCmds & 223 + 0xFF00;
  13261. $response = "configuration request send";
  13262. $logLevel = 2;
  13263. } elsif ($waitingCmds & 128) {
  13264. # room control setup request waiting
  13265. $data = "0019";
  13266. # clear command
  13267. $waitingCmds = $waitingCmds & 127 + 0xFF00;
  13268. $response = "room control setup request send";
  13269. $logLevel = 2;
  13270. } elsif ($waitingCmds & 256) {
  13271. # time program request waiting
  13272. $data = "0021";
  13273. # clear command
  13274. $waitingCmds = $waitingCmds & 0xFEFF;
  13275. $response = "time program request send";
  13276. $logLevel = 2;
  13277. }
  13278. if ($waitingCmds == 0) {
  13279. CommandDeleteReading(undef, "$name waitingCmds");
  13280. } else {
  13281. readingsSingleUpdate($hash, "waitingCmds", $waitingCmds, 0);
  13282. }
  13283. } elsif ($mcf == 1) {
  13284. # message incomplete
  13285. $response = "acknowledge send, wating for next part of the message";
  13286. $logLevel = 2;
  13287. } elsif ($mcf == 2) {
  13288. # automatic message control
  13289. $response = "acknowledge send, automatic message control";
  13290. $logLevel = 2;
  13291. } elsif ($mcf == 3) {
  13292. # reserved
  13293. }
  13294. return ($err, $response, $data, $logLevel);
  13295. }
  13296. # create SVG devices
  13297. sub EnOcean_CreateSVG($$$)
  13298. {
  13299. my ($ctrl, $hash, $eepSVG) = @_;
  13300. my $name = $hash->{NAME};
  13301. my ($autocreateHash, $autocreateName, $autocreateDeviceRoom, $autocreateWeblinkRoom) =
  13302. (undef, 'autocreate', 'EnOcean', 'Plots');
  13303. my $filelogName = "FileLog_$name";
  13304. my ($cmd, $eep, $weblinkName, $weblinkHash, $ret);
  13305. if (defined($eepSVG) && $eepSVG =~ m/^([A-Za-z0-9]{2})-([A-Za-z0-9]{2})-([A-Za-z0-9]{2})$/i) {
  13306. $eep = uc("$1.$2.$3");
  13307. } 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) {
  13308. $eep = uc("$1.$2.$3");
  13309. } else {
  13310. return undef;
  13311. }
  13312. # find autocreate device
  13313. while (($autocreateName, $autocreateHash) = each(%defs)) {
  13314. last if ($defs{$autocreateName}{TYPE} eq "autocreate");
  13315. }
  13316. # delete old SVG devices
  13317. if (defined($ctrl) && $ctrl eq 'del' || !exists($defs{$filelogName})) {
  13318. while (($weblinkName, $weblinkHash) = each(%defs)) {
  13319. if ($weblinkName =~ /^SVG_$name.*/) {
  13320. CommandDelete(undef, $weblinkName);
  13321. Log3 $hash->{NAME}, 5, "EnOcean_CreateSVG: device $weblinkName deleted";
  13322. }
  13323. }
  13324. }
  13325. if (!defined(AttrVal($autocreateName, "disable", undef)) && exists($defs{$filelogName})) {
  13326. if (exists $EnO_eepConfig{$eep}{GPLOT}) {
  13327. # add GPLOT parameters
  13328. $attr{$filelogName}{logtype} = $EnO_eepConfig{$eep}{GPLOT} . $attr{$filelogName}{logtype}
  13329. if (!exists($attr{$filelogName}{logtype}) || $attr{$filelogName}{logtype} eq 'text');
  13330. if (AttrVal($autocreateName, "weblink", 1)) {
  13331. $autocreateWeblinkRoom = $attr{$autocreateName}{weblink_room} if (exists $attr{$autocreateName}{weblink_room});
  13332. $autocreateWeblinkRoom = 'EnOcean' if ($autocreateWeblinkRoom eq '%TYPE');
  13333. $autocreateWeblinkRoom = $name if ($autocreateWeblinkRoom eq '%NAME');
  13334. $autocreateWeblinkRoom = $attr{$name}{room} if (exists $attr{$name}{room});
  13335. my $wnr = 1;
  13336. #create SVG devices
  13337. foreach my $wdef (split(/,/, $EnO_eepConfig{$eep}{GPLOT})) {
  13338. next if(!$wdef);
  13339. my ($gplotfile, $stuff) = split(/:/, $wdef);
  13340. next if(!$gplotfile);
  13341. $weblinkName = "SVG_$name";
  13342. $weblinkName .= "_$wnr" if($wnr > 1);
  13343. $wnr++;
  13344. next if (exists $defs{$weblinkName});
  13345. $cmd = "$weblinkName SVG $filelogName:$gplotfile:CURRENT";
  13346. Log3 $weblinkName, 2, "EnOcean define $cmd";
  13347. $ret = CommandDefine(undef, $cmd);
  13348. if($ret) {
  13349. Log3 $weblinkName, 2, "EnOcean ERROR: define $cmd: $ret";
  13350. last;
  13351. }
  13352. $attr{$weblinkName}{room} = $autocreateWeblinkRoom;
  13353. $attr{$weblinkName}{title} = '"' . $name . ' Min $data{min1}, Max $data{max1}, Last $data{currval1}"';
  13354. $ret = CommandSet(undef, "$weblinkName copyGplotFile");
  13355. if($ret) {
  13356. Log3 $weblinkName, 2, "EnOcean ERROR: set $weblinkName copyGplotFile: $ret";
  13357. last;
  13358. }
  13359. }
  13360. }
  13361. }
  13362. }
  13363. return undef;
  13364. }
  13365. #CommandSave
  13366. sub EnOcean_CommandSave($$)
  13367. {
  13368. my ($ctrl, $param) = @_;
  13369. # find autocreate device
  13370. my ($autocreateHash, $autocreateName);
  13371. while (($autocreateName, $autocreateHash) = each(%defs)) {
  13372. last if ($defs{$autocreateName}{TYPE} eq "autocreate");
  13373. }
  13374. my $autosave = AttrVal($autocreateName, "autosave", undef);
  13375. if (!defined $autosave) {
  13376. CommandSave($ctrl, $param) if (AttrVal("global", "autosave", 1));
  13377. } elsif ($autosave) {
  13378. CommandSave($ctrl, $param);
  13379. }
  13380. return;
  13381. }
  13382. sub EnOcean_readingsSingleUpdate($) {
  13383. my ($readingParam) = @_;
  13384. my ($hash, $readingName, $readingVal, $ctrl, $log) = @$readingParam;
  13385. if (defined $hash) {
  13386. readingsSingleUpdate($hash, $readingName, $readingVal, $ctrl) ;
  13387. Log3 $hash->{NAME}, $log, "EnOcean " . $hash->{NAME} . " EVENT $readingName: $readingVal" if ($log);
  13388. }
  13389. return;
  13390. }
  13391. sub EnOcean_4BSRespWait($$$) {
  13392. my ($ctrl, $hash, $subDef) = @_;
  13393. my $IODev = $hash->{IODev}{NAME};
  13394. my $IOHash = $defs{$IODev};
  13395. $hash->{IODev}{helper}{"4BSRespWait"}{$subDef}{teachInReq} = "out";
  13396. $hash->{IODev}{helper}{"4BSRespWait"}{$subDef}{hash} = $hash;
  13397. if (!exists($hash->{IODev}{Teach})) {
  13398. # enable teach-in receiving for 3 sec
  13399. $hash->{IODev}{Teach} = 1;
  13400. my %timeoutHash = (hash => $IOHash, function => "4BSRespTimeout", helper => "4BSRespWait");
  13401. RemoveInternalTimer(\%timeoutHash);
  13402. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  13403. }
  13404. return;
  13405. }
  13406. # Check SenderIDs
  13407. sub EnOcean_CheckSenderID($$$)
  13408. {
  13409. my ($ctrl, $IODev, $senderID) = @_;
  13410. if (!defined $IODev) {
  13411. my (@listIODev, %listIODev);
  13412. foreach my $dev (keys %defs) {
  13413. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13414. push(@listIODev, $defs{$dev}{IODev}{NAME});
  13415. }
  13416. @listIODev = sort grep(!$listIODev{$_}++, @listIODev);
  13417. if (@listIODev == 1) {
  13418. $IODev = $listIODev[0];
  13419. }
  13420. }
  13421. my $unusedID = 0;
  13422. $unusedID = hex($defs{$IODev}{BaseID}) if ($defs{$IODev}{BaseID});
  13423. my $IDCntr1;
  13424. my $IDCntr2;
  13425. if ($unusedID == 0) {
  13426. $IDCntr1 = 0;
  13427. $IDCntr2 = 0;
  13428. } else {
  13429. $IDCntr1 = $unusedID + 1;
  13430. $IDCntr2 = $unusedID + 127;
  13431. }
  13432. if ($ctrl eq "getBaseID") {
  13433. # get TCM BaseID of the EnOcean device
  13434. if ($defs{$IODev}{BaseID}) {
  13435. $senderID = $defs{$IODev}{BaseID}
  13436. } else {
  13437. $senderID = "0" x 8;
  13438. }
  13439. } elsif ($ctrl eq "getUsedID") {
  13440. # find and sort used SenderIDs
  13441. my @listID;
  13442. my %listID;
  13443. foreach my $dev (keys %defs) {
  13444. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13445. push(@listID, grep(hex($_) >= $IDCntr1 && hex($_) <= $IDCntr2, $defs{$dev}{DEF}));
  13446. push(@listID, $attr{$dev}{subDef}) if ($attr{$dev}{subDef});
  13447. push(@listID, $attr{$dev}{subDefA}) if ($attr{$dev}{subDefA});
  13448. push(@listID, $attr{$dev}{subDefB}) if ($attr{$dev}{subDefB});
  13449. push(@listID, $attr{$dev}{subDefC}) if ($attr{$dev}{subDefC});
  13450. push(@listID, $attr{$dev}{subDefD}) if ($attr{$dev}{subDefD});
  13451. push(@listID, $attr{$dev}{subDefI}) if ($attr{$dev}{subDefI});
  13452. push(@listID, $attr{$dev}{subDefH}) if ($attr{$dev}{subDefH});
  13453. push(@listID, $attr{$dev}{subDefW}) if ($attr{$dev}{subDefW});
  13454. push(@listID, $attr{$dev}{subDef0}) if ($attr{$dev}{subDef0});
  13455. }
  13456. $senderID = join(" ", sort grep(!$listID{$_}++, @listID));
  13457. } elsif ($ctrl eq "getFreeID") {
  13458. # find and sort free SenderIDs
  13459. my (@freeID, @listID, %listID, @intersection, @difference, %count, $element);
  13460. for (my $IDCntr = $IDCntr1; $IDCntr <= $IDCntr2; $IDCntr++) {
  13461. push(@freeID, sprintf "%08X", $IDCntr);
  13462. }
  13463. foreach my $dev (keys %defs) {
  13464. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13465. push(@listID, grep(hex($_) >= $IDCntr1 && hex($_) <= $IDCntr2, $defs{$dev}{DEF}));
  13466. push(@listID, $attr{$dev}{subDef}) if ($attr{$dev}{subDef} && $attr{$dev}{subDef} ne "00000000");
  13467. push(@listID, $attr{$dev}{subDefA}) if ($attr{$dev}{subDefA} && $attr{$dev}{subDefA} ne "00000000");
  13468. push(@listID, $attr{$dev}{subDefB}) if ($attr{$dev}{subDefB} && $attr{$dev}{subDefB} ne "00000000");
  13469. push(@listID, $attr{$dev}{subDefC}) if ($attr{$dev}{subDefC} && $attr{$dev}{subDefC} ne "00000000");
  13470. push(@listID, $attr{$dev}{subDefD}) if ($attr{$dev}{subDefD} && $attr{$dev}{subDefD} ne "00000000");
  13471. push(@listID, $attr{$dev}{subDefI}) if ($attr{$dev}{subDefI} && $attr{$dev}{subDefI} ne "00000000");
  13472. push(@listID, $attr{$dev}{subDefH}) if ($attr{$dev}{subDefH} && $attr{$dev}{subDefH} ne "00000000");
  13473. push(@listID, $attr{$dev}{subDefW}) if ($attr{$dev}{subDefW} && $attr{$dev}{subDefW} ne "00000000");
  13474. push(@listID, $attr{$dev}{subDef0}) if ($attr{$dev}{subDef0} && $attr{$dev}{subDef0} ne "00000000");
  13475. }
  13476. @listID = sort grep(!$listID{$_}++, @listID);
  13477. foreach $element (@listID, @freeID) {
  13478. $count{$element}++
  13479. }
  13480. foreach $element (keys %count) {
  13481. push @{$count{$element} > 1 ? \@intersection : \@difference }, $element;
  13482. }
  13483. $senderID = ':' . join(" ", sort @difference);
  13484. } elsif ($ctrl eq "getNextID") {
  13485. # get next free SenderID
  13486. my (@freeID, @listID, %listID, @intersection, @difference, %count, $element);
  13487. for (my $IDCntr = $IDCntr1; $IDCntr <= $IDCntr2; $IDCntr++) {
  13488. push(@freeID, sprintf "%08X", $IDCntr);
  13489. }
  13490. foreach my $dev (keys %defs) {
  13491. next if ($defs{$dev}{TYPE} ne "EnOcean");
  13492. push(@listID, grep(hex($_) >= $IDCntr1 && hex($_) <= $IDCntr2, $defs{$dev}{DEF}));
  13493. push(@listID, $attr{$dev}{subDef}) if ($attr{$dev}{subDef} && $attr{$dev}{subDef} ne "00000000");
  13494. push(@listID, $attr{$dev}{subDefA}) if ($attr{$dev}{subDefA} && $attr{$dev}{subDefA} ne "00000000");
  13495. push(@listID, $attr{$dev}{subDefB}) if ($attr{$dev}{subDefB} && $attr{$dev}{subDefB} ne "00000000");
  13496. push(@listID, $attr{$dev}{subDefC}) if ($attr{$dev}{subDefC} && $attr{$dev}{subDefC} ne "00000000");
  13497. push(@listID, $attr{$dev}{subDefD}) if ($attr{$dev}{subDefD} && $attr{$dev}{subDefD} ne "00000000");
  13498. push(@listID, $attr{$dev}{subDefI}) if ($attr{$dev}{subDefI} && $attr{$dev}{subDefI} ne "00000000");
  13499. push(@listID, $attr{$dev}{subDefH}) if ($attr{$dev}{subDefH} && $attr{$dev}{subDefH} ne "00000000");
  13500. push(@listID, $attr{$dev}{subDefW}) if ($attr{$dev}{subDefW} && $attr{$dev}{subDefW} ne "00000000");
  13501. push(@listID, $attr{$dev}{subDef0}) if ($attr{$dev}{subDef0} && $attr{$dev}{subDef0} ne "00000000");
  13502. }
  13503. @listID = sort grep(!$listID{$_}++, @listID);
  13504. foreach $element (@listID, @freeID) {
  13505. $count{$element}++
  13506. }
  13507. foreach $element (keys %count) {
  13508. push @{$count{$element} > 1 ? \@intersection : \@difference }, $element;
  13509. }
  13510. @difference = sort @difference;
  13511. if (defined $difference[0]) {
  13512. $senderID = $difference[0];
  13513. } else {
  13514. $senderID = "0" x 8;
  13515. Log3 $IODev, 2, "EnOcean $IODev no free senderIDs available";
  13516. }
  13517. } else {
  13518. }
  13519. return $senderID;
  13520. }
  13521. # assign next free SenderID
  13522. sub EnOcean_AssignSenderID($$$$)
  13523. {
  13524. my ($ctrl, $hash, $attrName, $comMode) = @_;
  13525. my $def = $hash->{DEF};
  13526. my $err;
  13527. my $name = $hash->{NAME};
  13528. my $IODev = $hash->{IODev}{NAME};
  13529. my $senderID = AttrVal($name, $attrName, "");
  13530. # SenderID valid
  13531. return ($err, $senderID) if ($senderID =~ m/^[\dA-Fa-f]{8}$/);
  13532. return ("no IODev", $def) if (!defined $IODev);
  13533. # DEF is SenderID
  13534. if (hex($def) >= hex($defs{$IODev}{BaseID}) && hex($def) <= hex($defs{$IODev}{BaseID}) + 127) {
  13535. if ($comMode eq "biDir") {
  13536. $attr{$name}{comMode} = $comMode;
  13537. } else {
  13538. $attr{$name}{comMode} = "uniDir";
  13539. }
  13540. return ($err, $def);
  13541. } else {
  13542. if ($comMode eq "biDir") {
  13543. $attr{$name}{comMode} = $comMode;
  13544. } else {
  13545. $attr{$name}{comMode} = "confirm";
  13546. }
  13547. $senderID = EnOcean_CheckSenderID("getNextID", $IODev, "00000000");
  13548. }
  13549. #Log3 $name, 2, "EnOcean $name SenderID: $senderID assigned";
  13550. #CommandAttr(undef, "$name $attrName $senderID");
  13551. $attr{$name}{$attrName} = $senderID;
  13552. return ($err, $senderID);
  13553. }
  13554. # split chained data message
  13555. sub EnOcean_SndCdm($$$$$$$$)
  13556. {
  13557. my ($ctrl, $hash, $packetType, $rorg, $data, $senderID, $status, $destinationID) = @_;
  13558. if (!defined $data) {
  13559. Log3 $hash->{NAME}, 5, "EnOcean $hash->{NAME} EnOcean_SndCDM SenderID: $senderID DestinationID: $destinationID " .
  13560. "PacketType: $packetType RORG: $rorg DATA: undef STATUS: $status";
  13561. return;
  13562. }
  13563. my ($seq, $idx, $len, $dataPart, $dataPartLen) = (0, 0, length($data) / 2, undef, 14);
  13564. # split telelegram with optional data
  13565. $dataPartLen = 9 if ($destinationID ne "FFFFFFFF");
  13566. if ($packetType == 1 && $len > $dataPartLen) {
  13567. # first CDM telegram
  13568. if ($dataPartLen == 14) {
  13569. $data =~ m/^(....................)(.*)$/;
  13570. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . (sprintf "%04X", $len) . $rorg . $1;
  13571. $data = $2;
  13572. } else {
  13573. $data =~ m/^(..........)(.*)$/;
  13574. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . (sprintf "%04X", $len) . $rorg . $1;
  13575. $data = $2;
  13576. }
  13577. $idx ++;
  13578. $len -= $dataPartLen - 5;
  13579. EnOcean_SndRadio($ctrl, $hash, $packetType, "40", $dataPart, $senderID, $status, $destinationID);
  13580. while ($len > 0) {
  13581. if ($len > $dataPartLen - 2) {
  13582. if ($dataPartLen == 14) {
  13583. $data =~ m/^(..........................)(.*)$/;
  13584. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . $1;
  13585. $data = $2;
  13586. } else {
  13587. $data =~ m/^(................)(.*)$/;
  13588. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . $1;
  13589. $data = $2;
  13590. }
  13591. $idx ++;
  13592. $len -= $dataPartLen - 2;
  13593. } else {
  13594. $dataPart = (sprintf "%02X", $seq << 6 | $idx) . $data;
  13595. $len = 0;
  13596. }
  13597. EnOcean_SndRadio($ctrl, $hash, $packetType, "40", $dataPart, $senderID, $status, $destinationID);
  13598. }
  13599. } else {
  13600. # not necessary to split
  13601. EnOcean_SndRadio($ctrl, $hash, $packetType, $rorg, $data, $senderID, $status, $destinationID);
  13602. }
  13603. return;
  13604. }
  13605. # send ESP3 Packet Type Radio
  13606. sub EnOcean_SndRadio($$$$$$$$)
  13607. {
  13608. my ($ctrl, $hash, $packetType, $rorg, $data, $senderID, $status, $destinationID) = @_;
  13609. if (!defined $data) {
  13610. Log3 $hash->{NAME}, 5, "EnOcean $hash->{NAME} EnOcean_SndRadio SenderID: $senderID DestinationID: $destinationID " .
  13611. "PacketType: $packetType RORG: $rorg DATA: undef STATUS: $status";
  13612. return;
  13613. }
  13614. my ($err, $response, $loglevel);
  13615. my $header;
  13616. my $odata = "";
  13617. my $odataLength = 0;
  13618. if ($packetType == 1) {
  13619. ($err, $rorg, $data, $response, $loglevel) = EnOcean_sec_convertToSecure($hash, $packetType, $rorg, $data);
  13620. if (defined $err) {
  13621. Log3 $hash->{NAME}, $loglevel, "EnOcean $hash->{NAME} Error: $err";
  13622. return "";
  13623. }
  13624. if (AttrVal($hash->{NAME}, "repeatingAllowed", "yes") eq "no") {
  13625. $status = substr($status, 0, 1) . "F";
  13626. }
  13627. if ($rorg eq "A6") {
  13628. # ADT telegram
  13629. $data .= $destinationID;
  13630. } elsif ($destinationID ne "FFFFFFFF") {
  13631. # SubTelNum = 03, DestinationID:8, RSSI = FF, secLevel = 00
  13632. $odata = sprintf "03%sFF00", $destinationID;
  13633. $odataLength = 7;
  13634. }
  13635. # Data Length:4 Optional Length:2 Packet Type:2
  13636. $header = sprintf "%04X%02X%02X", (length($data) / 2 + 6), $odataLength, $packetType;
  13637. Log3 $hash->{NAME}, 4, "EnOcean $hash->{NAME} sent PacketType: $packetType RORG: $rorg DATA: $data SenderID: $senderID STATUS: $status ODATA: $odata";
  13638. $data = $rorg . $data . $senderID . $status . $odata;
  13639. } elsif ($packetType == 2 || $packetType == 6) {
  13640. # smart ack commands
  13641. # Data Length:4 Optional Length:2 Packet Type:2
  13642. $header = sprintf "%04X%02X%02X", length($data) / 2, 0, $packetType;
  13643. Log3 $hash->{NAME}, 4, "EnOcean $hash->{NAME} sent PacketType: $packetType DATA: $data";
  13644. } elsif ($packetType == 7) {
  13645. my $delay = 0;
  13646. $delay = 1 if ($destinationID eq "FFFFFFFF");
  13647. $senderID = "00000000";
  13648. #$senderID = "00000000" if ($destinationID eq "FFFFFFFF");
  13649. $odata = sprintf "%s%sFF%02X", $destinationID, $senderID, $delay;
  13650. $odataLength = 10;
  13651. # Data Length:4 Optional Length:2 Packet Type:2
  13652. $header = sprintf "%04X%02X%02X", (length($data) / 2), $odataLength, $packetType;
  13653. Log3 $hash->{NAME}, 4, "EnOcean $hash->{NAME} sent PacketType: $packetType DATA: $data ODATA: $odata";
  13654. $data .= $odata;
  13655. }
  13656. if (defined $ctrl) {
  13657. # sent telegram delayed
  13658. my @param = ($hash, $header, $data);
  13659. InternalTimer(gettimeofday() + $ctrl, 'EnOcean_IOWriteTimer', \@param, 0);
  13660. } else {
  13661. IOWrite($hash, $header, $data);
  13662. }
  13663. return;
  13664. }
  13665. #
  13666. sub EnOcean_IOWriteTimer($)
  13667. {
  13668. my ($ioParam) = @_;
  13669. my ($hash, $header, $data) = @$ioParam;
  13670. IOWrite($hash, $header, $data);
  13671. return;
  13672. }
  13673. # Scale Readings
  13674. sub EnOcean_ReadingScaled($$$$)
  13675. {
  13676. my ($hash, $readingVal, $readingMin, $readingMax) = @_;
  13677. my $name = $hash->{NAME};
  13678. my $valScaled;
  13679. my $scaleDecimals = AttrVal($name, "scaleDecimals", undef);
  13680. my $scaleMin = AttrVal($name, "scaleMin", undef);
  13681. my $scaleMax = AttrVal($name, "scaleMax", undef);
  13682. if (defined $scaleMax && defined $scaleMin &&
  13683. $scaleMax =~ m/^[+-]?\d+(\.\d+)?$/ && $scaleMin =~ m/^[+-]?\d+(\.\d+)?$/) {
  13684. $valScaled = ($readingMin*$scaleMax-$scaleMin*$readingMax)/
  13685. ($readingMin-$readingMax)+
  13686. ($scaleMin-$scaleMax)/($readingMin-$readingMax)*$readingVal;
  13687. }
  13688. if (defined $scaleDecimals && $scaleDecimals =~ m/^[0-9]?$/) {
  13689. $scaleDecimals = "%0." . $scaleDecimals . "f";
  13690. $valScaled = sprintf "$scaleDecimals", $valScaled;
  13691. }
  13692. return $valScaled;
  13693. }
  13694. # Reorganize Strings
  13695. sub EnOcean_ReorgList($)
  13696. {
  13697. my ($list) = @_;
  13698. my @list = split("[ \t][ \t]*", $list);
  13699. my %list;
  13700. @list = sort grep(!$list{$_}++, @list);
  13701. $list = join(" ", @list) . " ";
  13702. return $list;
  13703. }
  13704. # EnOcean_Set called from sub InternalTimer()
  13705. sub EnOcean_TimerSet($)
  13706. {
  13707. my ($par) = @_;
  13708. EnOcean_Set($par->{hash}, @{$par->{timerCmd}});
  13709. }
  13710. #
  13711. sub EnOcean_InternalTimer($$$$$)
  13712. {
  13713. my ($modifier, $tim, $callback, $hash, $waitIfInitNotDone) = @_;
  13714. my $mHash = {};
  13715. my $timerName = "$hash->{NAME}_$modifier";
  13716. if ($modifier eq "") {
  13717. $mHash = $hash;
  13718. } else {
  13719. if (exists ($hash->{helper}{TIMER}{$timerName})) {
  13720. $mHash = $hash->{helper}{TIMER}{$timerName};
  13721. Log3 $hash->{NAME}, 5, "EnOcean_InternalTimer setting mHash with stored $timerName";
  13722. } else {
  13723. $mHash = {HASH => $hash, NAME => $timerName, MODIFIER => $modifier};
  13724. $hash->{helper}{TIMER}{$timerName} = $mHash;
  13725. Log3 $hash->{NAME}, 5, "EnOcean_InternalTimer setting mHash with $timerName";
  13726. }
  13727. }
  13728. InternalTimer($tim, $callback, $mHash, $waitIfInitNotDone);
  13729. Log3 $hash->{NAME}, 5, "EnOcean setting timer $timerName at " . strftime("%Y-%m-%d %H:%M:%S", localtime($tim));
  13730. return;
  13731. }
  13732. #
  13733. sub EnOcean_RemoveInternalTimer($$)
  13734. {
  13735. my ($modifier, $hash) = @_;
  13736. my $mHash = {};
  13737. my $timerName = "$hash->{NAME}_$modifier";
  13738. if ($modifier eq "") {
  13739. RemoveInternalTimer($hash);
  13740. } else {
  13741. $mHash = $hash->{helper}{TIMER}{$timerName};
  13742. if (defined($mHash)) {
  13743. delete $hash->{helper}{TIMER}{$timerName};
  13744. RemoveInternalTimer($mHash);
  13745. }
  13746. }
  13747. Log3 $hash->{NAME}, 5, "EnOcean removing timer $timerName";
  13748. return;
  13749. }
  13750. #
  13751. sub EnOcean_observeInit($$@)
  13752. {
  13753. #init observe
  13754. my ($ctrl, $hash, @cmdValue) = @_;
  13755. my ($err, $name) = (undef, $hash->{NAME});
  13756. return (undef, $ctrl) if (lc(AttrVal($name, "observe", "off")) eq "off");
  13757. return (undef, $ctrl) if (defined($hash->{helper}{observeCntr}) && $hash->{helper}{observeCntr} > 0);
  13758. $hash->{helper}{observeCntr} = 1;
  13759. #my @observeExeptions = split("[ \t][ \t]*", AttrVal($name, "observeExeptions", ""));
  13760. my @observeRefDev = split("[ \t][ \t]*", AttrVal($name, "observeRefDev", $name));
  13761. $hash->{helper}{observeRefDev} = \@observeRefDev;
  13762. Log3 $name, 4, "EnOcean $name < observeRefDev " . join(" ", @{$hash->{helper}{observeRefDev}}) . " (init)";
  13763. $hash->{helper}{lastCmdFunction} = "set";
  13764. # @cmdValue = (<name>, <cmd>, <param1>, <param2>, ...)
  13765. $hash->{helper}{lastCmdValue} = \@cmdValue;
  13766. my $observeCmds = AttrVal($name, "observeCmds", undef);
  13767. my @observeCmds;
  13768. #my %observeCmds;
  13769. my ($cmdPair, $cmdSent, $cmdReceived);
  13770. if (defined $observeCmds) {
  13771. @observeCmds = split("[ \t][ \t]*", $observeCmds);
  13772. foreach my $cmdPair (@observeCmds) {
  13773. ($cmdSent, $cmdReceived) = split(':', $cmdPair);
  13774. $hash->{helper}{observeCmds}{$cmdSent} = $cmdReceived;
  13775. }
  13776. } else {
  13777. $hash->{helper}{observeCmds}{$cmdValue[1]} = $cmdValue[1];
  13778. }
  13779. $hash->{helper}{observeCntr} = 1;
  13780. #CommandDeleteReading(undef, "$name observeFailedDev");
  13781. readingsSingleUpdate($hash, "observeFailedDev", "", 0);
  13782. my %functionHash = (hash => $hash, function => "observe");
  13783. RemoveInternalTimer(\%functionHash);
  13784. InternalTimer(gettimeofday() + AttrVal($name, "observeInterval", 1), "EnOcean_observeRepeat", \%functionHash, 0);
  13785. Log3 $name, 4, "EnOcean set " . join(" ", @cmdValue) . " observing started";
  13786. return ($err, $ctrl);
  13787. }
  13788. #
  13789. sub EnOcean_observeParse($$@)
  13790. {
  13791. # observe acknowledge
  13792. my ($ctrl, $hash, @cmdValue) = @_;
  13793. my ($err, $name) = (undef, $hash->{NAME});
  13794. return (undef, $ctrl) if (lc(AttrVal($name, "observe", "off")) eq "off");
  13795. # observing disabled or ignore second and following acknowledgment telegrams
  13796. return (undef, $ctrl) if (!exists($hash->{helper}{observeRefDev}) || @{$hash->{helper}{observeRefDev}} == 0);
  13797. my $devName = shift @cmdValue;
  13798. my $cmd = shift @cmdValue;
  13799. $cmd = shift @cmdValue if ($cmd eq "state");
  13800. my ($observeRefDevIdx) = grep{$hash->{helper}{observeRefDev}[$_] eq $devName} 0..$#{$hash->{helper}{observeRefDev}};
  13801. # device not observed
  13802. return (undef, $ctrl) if (!defined $observeRefDevIdx);
  13803. Log3 $name, 4, "EnOcean $name < observeRefDev " . join(" ", @{$hash->{helper}{observeRefDev}}) . " parsed";
  13804. Log3 $name, 4, "EnOcean $name < $devName $cmd " . join(" ", @cmdValue) . " received";
  13805. if (@{$hash->{helper}{observeRefDev}} == 1) {
  13806. # last acknowledgment telegram stops observing
  13807. delete $hash->{helper}{observeCmds};
  13808. delete $hash->{helper}{observeCntr};
  13809. delete $hash->{helper}{observeRefDev};
  13810. delete $hash->{helper}{lastCmdFunction};
  13811. delete $hash->{helper}{lastCmdValue};
  13812. my %functionHash = (hash => $hash, function => "observe");
  13813. RemoveInternalTimer(\%functionHash);
  13814. Log3 $name, 4, "EnOcean $name < $devName $cmd " . join(" ", @cmdValue) . " observing stopped";
  13815. } else {
  13816. # remove the device that has sent a telegram
  13817. Log3 $name, 4, "EnOcean $name < observeRefDev " . $hash->{helper}{observeRefDev}[$observeRefDevIdx] . " removed";
  13818. splice(@{$hash->{helper}{observeRefDev}}, $observeRefDevIdx, 1);
  13819. if (lc(AttrVal($name, "observeLogic", "or")) eq "and") {
  13820. # AND logic: remove the device that has sent a telegram and await further telegrams
  13821. Log3 $name, 4, "EnOcean $name < observeRefDev " . join(" ", @{$hash->{helper}{observeRefDev}}) . " observing continued";
  13822. } else {
  13823. # OR logic: last acknowledgment telegram stops observing
  13824. #shift @{$hash->{helper}{observeRefDev}};
  13825. delete $hash->{helper}{observeCmds};
  13826. delete $hash->{helper}{observeCntr};
  13827. delete $hash->{helper}{observeRefDev};
  13828. delete $hash->{helper}{lastCmdFunction};
  13829. delete $hash->{helper}{lastCmdValue};
  13830. my %functionHash = (hash => $hash, function => "observe");
  13831. RemoveInternalTimer(\%functionHash);
  13832. Log3 $name, 4, "EnOcean $name < $devName $cmd " . join(" ", @cmdValue) . " observing stopped";
  13833. }
  13834. }
  13835. # if (defined($hash->{helper}{lastCmdValue}[1]) && $hash->{helper}{lastCmdValue}[1] eq $cmd) {
  13836. # acknowledgment telegram ok, cancel the repetition of the command
  13837. # } else {
  13838. # acknowledgment telegram does not match the telegram sent, cancel the repetition of the command
  13839. # }
  13840. return ($err, $ctrl);
  13841. }
  13842. #
  13843. sub EnOcean_observeRepeat($)
  13844. {
  13845. #timer expires without acknowledgment telegram, repeat command
  13846. my ($functionHash) = @_;
  13847. my $hash = $functionHash->{hash};
  13848. my $name = $hash->{NAME};
  13849. return if (AttrVal($name, "observe", "off") eq "off" || !defined($hash->{helper}{observeCntr}));
  13850. #my @observeExeptions = split("[ \t][ \t]*", AttrVal($name, "observeExeptions", ""));
  13851. if ($hash->{helper}{observeCntr} <= AttrVal($name, "observeCmdRepetition", 2)) {
  13852. #repeat last command
  13853. $hash->{helper}{observeCntr} += 1;
  13854. Log3 $name, 4, "EnOcean set " . join(" ", @{$hash->{helper}{lastCmdValue}}) . " repeated";
  13855. EnOcean_Set($hash, @{$hash->{helper}{lastCmdValue}});
  13856. RemoveInternalTimer($functionHash);
  13857. InternalTimer(gettimeofday() + AttrVal($name, "observeInterval", 1), "EnOcean_observeRepeat", $functionHash, 0);
  13858. } else {
  13859. # reached the maximum number of retries, clear last command
  13860. Log3 $name, 2, "EnOcean set " . join(" ", @{$hash->{helper}{lastCmdValue}}) .
  13861. " observing " . join(" ", @{$hash->{helper}{observeRefDev}}) . " failed";
  13862. #splice(@{$hash->{helper}{observeRefDev}}, 0);
  13863. my $actionCmd = AttrVal($name, "observeErrorAction", undef);
  13864. if (defined $actionCmd) {
  13865. # error action exec
  13866. my %specials = ("%NAME" => shift(@{$hash->{helper}{lastCmdValue}}),
  13867. "%FAILEDDEV" => join(" ", @{$hash->{helper}{observeRefDev}}),
  13868. "%TYPE" => $hash->{TYPE},
  13869. "%EVENT" => ReplaceEventMap($name, join(" ", @{$hash->{helper}{lastCmdValue}}), 1)
  13870. );
  13871. $actionCmd = EvalSpecials($actionCmd, %specials);
  13872. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  13873. Log3 $name, 2, "EnOcean $name observeErrorAction ERROR: $ret" if($ret);
  13874. }
  13875. readingsSingleUpdate($hash, "observeFailedDev", join(" ", @{$hash->{helper}{observeRefDev}}), 1);
  13876. delete $hash->{helper}{observeCmds};
  13877. delete $hash->{helper}{observeCntr};
  13878. delete $hash->{helper}{observeRefDev};
  13879. delete $hash->{helper}{lastCmdFunction};
  13880. delete $hash->{helper}{lastCmdValue};
  13881. RemoveInternalTimer($functionHash);
  13882. }
  13883. return;
  13884. }
  13885. sub EnOcean_RLT($) {
  13886. # Radio Link Test
  13887. my ($rltParam) = @_;
  13888. my ($ctrl, $hash, $dataRx, $subDef, $rltMode, $rssiMaster) = @$rltParam;
  13889. my $name = $hash->{NAME};
  13890. my $def = $hash->{DEF};
  13891. my ($err, $logLevel, $response, $dataTx, $rorg, $msgID) = (undef, 5, undef, undef, undef, 0);
  13892. my $rltCntrMax = AttrVal($name, 'rltRepeat', 16);
  13893. my $rltType = AttrVal($name, 'rltType', '4BS');
  13894. if ($rltType eq '1BS') {
  13895. $msgID = $hash->{helper}{rlt}{cntr} & 0x3F if (exists($hash->{helper}{rlt}{cntr}));
  13896. $dataTx = sprintf("%02X", ($msgID & 0x3C) << 2 | 8 | ($msgID & 3) << 1);
  13897. $rorg = 'D5';
  13898. } else {
  13899. $dataTx = '0000000C';
  13900. $rorg = 'A5';
  13901. }
  13902. if ($ctrl eq 'start') {
  13903. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13904. $hash->{helper}{rlt}{cntr} = 0;
  13905. $hash->{helper}{rlt}{param}[0] = 'periodic';
  13906. readingsSingleUpdate($hash, 'state', 'active', 1);
  13907. EnOcean_SndRadio(undef, $hash, 1, $rorg, $dataTx, $subDef, "00", $def);
  13908. InternalTimer(gettimeofday() + 0.15, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  13909. } elsif ($ctrl eq 'parse') {
  13910. $hash->{helper}{rlt}{param}[0] = 'periodic';
  13911. if ($hash->{helper}{rlt}{cntr} < $rltCntrMax) {
  13912. # store received RLT data from slave
  13913. $hash->{helper}{rlt}{dataRx}[$hash->{helper}{rlt}{cntr}] = $dataRx;
  13914. $hash->{helper}{rlt}{rssiMaster}[$hash->{helper}{rlt}{cntr}] = $rssiMaster;
  13915. if ($hash->{helper}{rlt}{cntr} < $rltCntrMax - 1) {
  13916. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13917. $hash->{helper}{rlt}{cntr} ++;
  13918. EnOcean_SndRadio(undef, $hash, 1, $rorg, $dataTx, $subDef, "00", $def);
  13919. InternalTimer(gettimeofday() + 0.15, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  13920. }
  13921. } else {
  13922. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13923. readingsSingleUpdate($hash, 'state', 'stopped', 1);
  13924. EnOcean_RLTResult(undef, $hash, $rltType, $rltCntrMax);
  13925. if (exists $hash->{helper}{rlt}{oldDev}) {
  13926. # activate old device subType
  13927. my $oldHash = $hash->{helper}{rlt}{oldDev}[0];
  13928. my $oldName = $hash->{helper}{rlt}{oldDev}[1];
  13929. my $oldDef = $hash->{helper}{rlt}{oldDev}[2];
  13930. CommandModify(undef, "$oldName $oldDef");
  13931. $modules{EnOcean}{defptr}{$oldDef} = $oldHash;
  13932. }
  13933. delete $hash->{helper}{rlt};
  13934. # delete deviceID
  13935. CommandModify(undef, "$name 00000000");
  13936. delete $modules{EnOcean}{defptr}{$def};
  13937. }
  13938. } elsif ($ctrl eq 'periodic') {
  13939. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13940. if ($hash->{helper}{rlt}{cntr} < $rltCntrMax - 1) {
  13941. # no RLT_SlaveTest telegram received from slave
  13942. $hash->{helper}{rlt}{param}[0] = 'periodic';
  13943. $hash->{helper}{rlt}{cntr} ++;
  13944. EnOcean_SndRadio(undef, $hash, 1, $rorg, $dataTx, $subDef, "00", $def);
  13945. InternalTimer(gettimeofday() + 0.11, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  13946. } else {
  13947. # waiting for last RLT_SlaveTest telegram
  13948. $hash->{helper}{rlt}{param}[0] = 'waiting';
  13949. InternalTimer(gettimeofday() + 0.15, "EnOcean_RLT", $hash->{helper}{rlt}{param}, 0);
  13950. }
  13951. } elsif ($ctrl eq 'waiting') {
  13952. readingsSingleUpdate($hash, 'state', 'stopped', 1);
  13953. EnOcean_RLTResult(undef, $hash, $rltType, $rltCntrMax);
  13954. if (exists $hash->{helper}{rlt}{oldDev}) {
  13955. # activate old device subType
  13956. my $oldHash = $hash->{helper}{rlt}{oldDev}[0];
  13957. my $oldName = $hash->{helper}{rlt}{oldDev}[1];
  13958. my $oldDef = $hash->{helper}{rlt}{oldDev}[2];
  13959. CommandModify(undef, "$oldName $oldDef");
  13960. $modules{EnOcean}{defptr}{$oldDef} = $oldHash;
  13961. }
  13962. delete $hash->{helper}{rlt};
  13963. # delete deviceID
  13964. CommandModify(undef, "$name 00000000");
  13965. delete $modules{EnOcean}{defptr}{$def};
  13966. } elsif ($ctrl eq 'standby') {
  13967. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13968. delete $hash->{helper}{rlt};
  13969. readingsSingleUpdate($hash, 'state', 'standby', 1);
  13970. # delete deviceID
  13971. CommandModify(undef, "$name 00000000");
  13972. delete $modules{EnOcean}{defptr}{$def};
  13973. } elsif ($ctrl eq 'stop') {
  13974. RemoveInternalTimer($hash->{helper}{rlt}{param});
  13975. if (exists $hash->{helper}{rlt}{oldDev}) {
  13976. # activate old device subType
  13977. my $oldHash = $hash->{helper}{rlt}{oldDev}[0];
  13978. my $oldName = $hash->{helper}{rlt}{oldDev}[1];
  13979. my $oldDef = $hash->{helper}{rlt}{oldDev}[2];
  13980. CommandModify(undef, "$oldName $oldDef");
  13981. $modules{EnOcean}{defptr}{$oldDef} = $oldHash;
  13982. }
  13983. delete $hash->{helper}{rlt};
  13984. readingsSingleUpdate($hash, 'state', 'stopped', 1);
  13985. # delete deviceID
  13986. CommandModify(undef, "$name 00000000");
  13987. delete $modules{EnOcean}{defptr}{$def};
  13988. }
  13989. return ($err, $logLevel, $response);
  13990. }
  13991. sub EnOcean_RLTResult($$$$) {
  13992. # show RLT results
  13993. my ($ctrl, $hash, $rltType, $rltCntrMax) = @_;
  13994. my $name = $hash->{NAME};
  13995. my ($err, $logLevel, $response, $data, $msgCntr, $msgID, $subTelNum, $rssiMaster, $rssiMasterAvg, $rssiSlave, $rssiLevel1, $rssiLevel2, $rssiNonEnOcean) =
  13996. (undef, 5, undef, undef, 0, 0, 0, 0, 0, 0, 0, 0, 0);
  13997. my %rssi = (0 => '-', 1 => '>= -31', 2 => '-32', 0x3F => '<= -93');
  13998. my %rssiNonEnOcean =
  13999. (0 => '-',
  14000. 1 => '>= -31',
  14001. 2 => '-32 ... -37',
  14002. 3 => '-38 ... -43',
  14003. 4 => '-44 ... -49',
  14004. 5 => '-50 ... -55',
  14005. 6 => '-56 ... -61',
  14006. 7 => '-62 ... -67',
  14007. 8 => '-68 ... -73',
  14008. 9 => '-74 ... -79',
  14009. 10 => '-80 ... -85',
  14010. 11 => '<= -92');
  14011. for (my $cntr = 0; $cntr < $rltCntrMax; $cntr++) {
  14012. $data = $hash->{helper}{rlt}{dataRx}[$cntr];
  14013. if (defined $data) {
  14014. $msgCntr ++;
  14015. $rssiMaster = -$hash->{helper}{rlt}{rssiMaster}[$cntr];
  14016. $rssiMasterAvg += $rssiMaster;
  14017. if ($rltType eq '1BS') {
  14018. $msgID = (hex($data) & 0xF0) >> 6 | (hex($data) & 6) >> 1;
  14019. Log3 $name, 2, "EnOcean RLT DeviceID: " . $hash->{DEF} . " msgCntr: ". ($cntr + 1) . " msgID: $msgID RSSI Master: $rssiMaster response received";
  14020. } else {
  14021. $subTelNum = (hex(substr($data, 0, 2)) & 0xC0) >> 6;
  14022. $rssiLevel2 = hex(substr($data, 0, 2)) & 0x3F;
  14023. $rssiLevel2 = $rssi{$rssiLevel2} if (exists $rssi{$rssiLevel2});
  14024. $rssiLevel1 = hex(substr($data, 2, 2));
  14025. $rssiLevel1 = $rssi{$rssiLevel1} if (exists $rssi{$rssiLevel1});
  14026. $rssiSlave = hex(substr($data, 4, 2));
  14027. $rssiSlave = $rssi{$rssiSlave} if (exists $rssi{$rssiSlave});
  14028. $rssiNonEnOcean = (hex(substr($data, 6, 2)) & 0xF0) >> 4;
  14029. $rssiNonEnOcean = $rssiNonEnOcean{$rssiNonEnOcean} if (exists $rssiNonEnOcean{$rssiNonEnOcean});
  14030. $msgID = (hex(substr($data, 6, 2)) & 6) >> 1;
  14031. Log3 $name, 2, "EnOcean RLT DeviceID: " . $hash->{DEF} . " msgCntr: ". ($cntr + 1) . " subTelNum: $subTelNum " .
  14032. "RSSI Master: $rssiMaster RSSI Slave: $rssiSlave RSSI Level 1: $rssiLevel1 RSSI Level 2: $rssiLevel2 " .
  14033. "RSSI non EnOcean: $rssiNonEnOcean";
  14034. }
  14035. } else {
  14036. Log3 $name, 2, "EnOcean RLT DeviceID: " . $hash->{DEF} . " msgCntr: ". ($cntr + 1) . " no answer";
  14037. }
  14038. }
  14039. if ($msgCntr > 0) {
  14040. readingsBeginUpdate($hash);
  14041. readingsBulkUpdate($hash, 'msgLost', (sprintf "%0.1f", ($rltCntrMax - $msgCntr) / $rltCntrMax * 100));
  14042. readingsBulkUpdate($hash, 'rssiMasterAvg', (sprintf "%0.1f", $rssiMasterAvg / $msgCntr));
  14043. readingsEndUpdate($hash, 1);
  14044. } else {
  14045. CommandDeleteReading(undef, "$name msgLost");
  14046. CommandDeleteReading(undef, "$name rssiMasterAvg");
  14047. }
  14048. return ($err, $logLevel, $response);
  14049. }
  14050. #
  14051. sub EnOcean_energyManagement_01Parse($@)
  14052. {
  14053. my ($hash, @db) = @_;
  14054. my $name = $hash->{NAME};
  14055. # [drLevel] = 15 : no requests for reduction in power consumptions
  14056. my $drLevel = ($db[0] & 0xF0) >> 4;
  14057. my $powerUsage = $db[2] & 0x7F;
  14058. my $powerUsageLevel = $db[0] & 1 ? "max" : "min";
  14059. my $powerUsageScale = $db[2] & 0x80 ? "rel" : "max";
  14060. my $randomStart = $db[0] & 4 ? "yes" : "no";
  14061. my $randomEnd = $db[0] & 2 ? "yes" : "no";
  14062. my $randomTime = rand(AttrVal($name, "demandRespRandomTime", 1));
  14063. my $setpoint = $db[3];
  14064. my $timeout = $db[1] * 15 * 60;
  14065. $randomTime = $randomTime > $timeout && $timeout > 0 ? rand($timeout) : rand($randomTime);
  14066. readingsBeginUpdate($hash);
  14067. readingsBulkUpdate($hash, "randomEnd", $randomEnd);
  14068. readingsBulkUpdate($hash, "randomStart", $randomStart);
  14069. my %timeoutHash = (hash => $hash, function => "demandResponseTimeout");
  14070. my %functionHash = (hash => $hash,
  14071. function => "demandResponseExec",
  14072. drLevel => $drLevel,
  14073. powerUsage => $powerUsage,
  14074. powerUsageLevel => $powerUsageLevel,
  14075. powerUsageScale => $powerUsageScale,
  14076. setpoint => $setpoint
  14077. );
  14078. RemoveInternalTimer(\%timeoutHash);
  14079. RemoveInternalTimer(\%functionHash);
  14080. if ($timeout > 0 && $drLevel < 15) {
  14081. # timeout timer
  14082. InternalTimer(gettimeofday() + $timeout, "EnOcean_demandResponseTimeout", \%timeoutHash, 0);
  14083. my ($sec, $min, $hour, $day, $month, $year) = localtime(time + $timeout);
  14084. $month += 1;
  14085. $year += 1900;
  14086. $min = $min < 10 ? $min = "0" . $min : $min;
  14087. $hour = $hour < 10 ? $hour = "0" . $hour : $hour;
  14088. $day = $day < 10 ? $day = "0" . $day : $day;
  14089. $month = $month < 10 ? $ month = "0". $month : $month;
  14090. readingsBulkUpdate($hash, "timeout", "$year-$month-$day $hour:$min:$sec");
  14091. } else {
  14092. CommandDeleteReading(undef, "$name timeout");
  14093. }
  14094. if ($randomStart eq "yes" && ReadingsVal($name, "level", 15) == 15) {
  14095. readingsBulkUpdate($hash, "state", "waiting_for_start");
  14096. Log3 $name, 3, "EnOcean set $name demand response waiting for start";
  14097. InternalTimer(gettimeofday() + $randomTime, "EnOcean_demandResponseExec", \%functionHash, 0);
  14098. } elsif ($randomEnd eq "yes" && ReadingsVal($name, "level", 15) < 15) {
  14099. readingsBulkUpdate($hash, "state", "waiting_for_stop");
  14100. Log3 $name, 3, "EnOcean set $name demand response waiting for stop";
  14101. InternalTimer(gettimeofday() + $randomTime, "EnOcean_demandResponseExec", \%functionHash, 0);
  14102. } else {
  14103. EnOcean_demandResponseExec(\%functionHash);
  14104. }
  14105. readingsEndUpdate($hash, 1);
  14106. return;
  14107. }
  14108. #
  14109. sub EnOcean_demandResponseExec($)
  14110. {
  14111. my ($functionHash) = @_;
  14112. my $function = $functionHash->{function};
  14113. my $hash = $functionHash->{hash};
  14114. my $drLevel = $functionHash->{drLevel};
  14115. my $powerUsage = $functionHash->{powerUsage};
  14116. my $powerUsageLevel = $functionHash->{powerUsageLevel};
  14117. my $powerUsageScale = $functionHash->{powerUsageScale};
  14118. my $setpoint = $functionHash->{setpoint};
  14119. my $name = $hash->{NAME};
  14120. my $actionCmd = AttrVal($name, "demandRespAction", undef);
  14121. # save old values
  14122. $hash->{helper}{drLevel} = ReadingsVal($name, "level", 15);
  14123. $hash->{helper}{powerUsage} = ReadingsVal($name, "powerUsage", 100);
  14124. $hash->{helper}{powerUsageLevel} = ReadingsVal($name, "powerUsageLevel", "max");
  14125. $hash->{helper}{powerUsageScale} = ReadingsVal($name, "powerUsageScale", "max");
  14126. $hash->{helper}{setpoint} = ReadingsVal($name, "setpoint", 255);
  14127. readingsBeginUpdate($hash);
  14128. readingsBulkUpdate($hash, "level", $drLevel);
  14129. readingsBulkUpdate($hash, "powerUsage", $powerUsage);
  14130. readingsBulkUpdate($hash, "powerUsageLevel", $powerUsageLevel);
  14131. readingsBulkUpdate($hash, "powerUsageScale", $powerUsageScale);
  14132. readingsBulkUpdate($hash, "setpoint", $setpoint);
  14133. if ($drLevel == 15) {
  14134. readingsBulkUpdate($hash, "state", "off");
  14135. Log3 $name, 3, "EnOcean set $name demand response off";
  14136. } else {
  14137. readingsBulkUpdate($hash, "state", "on");
  14138. Log3 $name, 3, "EnOcean set $name demand response on";
  14139. }
  14140. readingsEndUpdate($hash, 1);
  14141. if (defined $actionCmd) {
  14142. # action exec
  14143. my %specials= ("%NAME" => $name,
  14144. "%TYPE" => $hash->{TYPE},
  14145. "%LEVEL" => $drLevel,
  14146. "%SETPOINT" => $setpoint,
  14147. "%POWERUSAGE" => $powerUsage,
  14148. "%POWERUSAGESCALE" => $powerUsageScale,
  14149. "%POWERUSAGELEVEL" => $powerUsageLevel,
  14150. "%STATE" => ReadingsVal($name, "state", "off")
  14151. );
  14152. $actionCmd = EvalSpecials($actionCmd, %specials);
  14153. my $ret = AnalyzeCommandChain(undef, $actionCmd);
  14154. Log3 $name, 2, "EnOcean $name demandRespAction ERROR: $ret" if($ret);
  14155. }
  14156. return;
  14157. }
  14158. #
  14159. sub EnOcean_demandResponseTimeout($)
  14160. {
  14161. my ($functionHash) = @_;
  14162. my $function = $functionHash->{function};
  14163. my $hash = $functionHash->{hash};
  14164. my $name = $hash->{NAME};
  14165. my $actionCmd = AttrVal($name, "demandRespAction", undef);
  14166. my $data;
  14167. my $timeoutLevel = AttrVal($name, "demandRespTimeoutLevel", "max");
  14168. RemoveInternalTimer($functionHash);
  14169. CommandDeleteReading(undef, "$name timeout");
  14170. my $drLevel = 15;
  14171. my $powerUsage = 100;
  14172. my $powerUsageLevel = "max";
  14173. my $powerUsageScale = "max";
  14174. my $setpoint = 255;
  14175. my $timeout = 0;
  14176. if ($timeoutLevel eq "last" && defined($hash->{helper}{drLevel})) {
  14177. # restore old values
  14178. $drLevel = $hash->{helper}{drLevel};
  14179. $powerUsage = $hash->{helper}{powerUsage};
  14180. $powerUsageScale = $hash->{helper}{powerUsageLevel};
  14181. $powerUsageLevel = $hash->{helper}{powerUsageScale};
  14182. $setpoint = $hash->{helper}{setpoint};
  14183. }
  14184. readingsBeginUpdate($hash);
  14185. readingsBulkUpdate($hash, "level", $drLevel);
  14186. readingsBulkUpdate($hash, "powerUsage", $powerUsage);
  14187. readingsBulkUpdate($hash, "powerUsageLevel", $powerUsageLevel);
  14188. readingsBulkUpdate($hash, "powerUsageScale", $powerUsageScale);
  14189. readingsBulkUpdate($hash, "setpoint", $setpoint);
  14190. if ($drLevel == 15) {
  14191. readingsBulkUpdate($hash, "state", "off");
  14192. Log3 $name, 3, "EnOcean set $name demand response off";
  14193. } else {
  14194. readingsBulkUpdate($hash, "state", "on");
  14195. Log3 $name, 3, "EnOcean set $name demand response on";
  14196. }
  14197. readingsEndUpdate($hash, 1);
  14198. my %specials= ("%NAME" => $name,
  14199. "%TYPE" => $hash->{TYPE},
  14200. "%LEVEL" => $drLevel,
  14201. "%SETPOINT" => $setpoint,
  14202. "%POWERUSAGE" => $powerUsage,
  14203. "%POWERUSAGESCALE" => $powerUsageScale,
  14204. "%POWERUSAGELEVEL" => $powerUsageLevel,
  14205. "%STATE" => ReadingsVal($name, "state", "off")
  14206. );
  14207. $powerUsageLevel = $powerUsageLevel eq "max" ? 1 : 0;
  14208. $powerUsageScale = $powerUsageScale eq "rel" ? 0x80 : 0;
  14209. my $randomStart = ReadingsVal($name, "randomStart", "no") eq "yes" ? 4 : 0;
  14210. my $randomEnd = ReadingsVal($name, "randomEnd", "no") eq "yes" ? 2 : 0;
  14211. $data = sprintf "%02X%02X%02X%02X", $setpoint, $powerUsageScale | $powerUsage, $timeout,
  14212. $drLevel << 4 | $randomStart | $randomEnd | $powerUsageLevel | 8;
  14213. EnOcean_SndRadio(undef, $hash, 1, "A5", $data, AttrVal($name, "subDef", $hash->{DEF}), "00", "FFFFFFFF");
  14214. if (defined $actionCmd) {
  14215. # action exec
  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. # Send UTE Teach-In Telegrams
  14223. sub EnOcean_sndUTE($$$$$$$) {
  14224. my ($ctrl, $hash, $comMode, $responseRequest, $teachInReq, $devChannel, $eep) = @_;
  14225. my $name = $hash->{NAME};
  14226. my ($err, $data) = (undef, "");
  14227. my $IODev = $hash->{IODev}{NAME};
  14228. my $IOHash = $defs{$IODev};
  14229. my @db = (undef, undef, undef, "07", "FF", $devChannel);
  14230. if ($eep =~ m/^(..)-(..)-(..)$/) {
  14231. ($db[0], $db[1], $db[2]) = ($1, $2, $3);
  14232. } else {
  14233. return (1, undef, undef);
  14234. }
  14235. # set unidir/bidir operation
  14236. $db[6] = $comMode eq "biDir" ? 0x80 : 0;
  14237. $attr{$name}{comMode} = $comMode;
  14238. # set teach mode
  14239. if ($teachInReq eq "out") {
  14240. $db[6] |= 0x10;
  14241. } elsif ($teachInReq eq "inout") {
  14242. $db[6] |= 0x20;
  14243. }
  14244. # set response message mode
  14245. if ($responseRequest eq "no") {
  14246. $db[6] |= 0x40;
  14247. readingsSingleUpdate($hash, "teach", "EEP $eep UTE query sent", 1);
  14248. } else {
  14249. # set flag for response request,
  14250. if ($teachInReq eq "in") {
  14251. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{teachInReq} = $teachInReq;
  14252. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{hash} = $hash;
  14253. } elsif ($teachInReq eq "out") {
  14254. $hash->{IODev}{helper}{UTERespWait}{AttrVal($name, "subDef", $hash->{DEF})}{teachInReq} = $teachInReq;
  14255. $hash->{IODev}{helper}{UTERespWait}{AttrVal($name, "subDef", $hash->{DEF})}{hash} = $hash;
  14256. } elsif ($teachInReq eq "inout") {
  14257. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{teachInReq} = $teachInReq;
  14258. $hash->{IODev}{helper}{UTERespWait}{$hash->{DEF}}{hash} = $hash;
  14259. }
  14260. readingsSingleUpdate($hash, "teach", "EEP $eep UTE query sent, response requested", 1);
  14261. if (!exists($hash->{IODev}{Teach})) {
  14262. # enable teach-in receiving for 3 sec
  14263. $hash->{IODev}{Teach} = 1;
  14264. my %timeoutHash = (hash => $IOHash, function => "UTERespTimeout", helper => "UTERespWait");
  14265. RemoveInternalTimer(\%timeoutHash);
  14266. InternalTimer(gettimeofday() + 3, "EnOcean_RespTimeout", \%timeoutHash, 0);
  14267. }
  14268. }
  14269. $attr{$name}{devChannel} = $devChannel;
  14270. $attr{$name}{eep} = $eep;
  14271. $attr{$name}{manufID} = "7FF";
  14272. $data = sprintf "%02X%02X%s%s%s%s%s", $db[6], $db[5], $db[4], $db[3], $db[2], $db[1], $db[0];
  14273. return ($err, "D4", $data);
  14274. }
  14275. #
  14276. sub EnOcean_RespTimeout($) {
  14277. my ($functionHash) = @_;
  14278. my $function = $functionHash->{function};
  14279. my $hash = $functionHash->{hash};
  14280. my $helper = $functionHash->{helper};
  14281. my $name = $hash->{NAME};
  14282. delete $hash->{helper}{$helper};
  14283. delete $hash->{Teach};
  14284. return;
  14285. }
  14286. #
  14287. sub EnOcean_setTeachConfirmWaitHash($) {
  14288. my ($ctrl, $hash) = @_;
  14289. if (AttrVal($hash->{NAME}, "teachMethod", "") eq 'confirm') {
  14290. $hash->{IODev}{helper}{teachConfirmWaitHash} = $hash;
  14291. my %functionHash = (hash => $hash->{IODev}, function => "teachConfirmWaitHash");
  14292. RemoveInternalTimer(\%functionHash);
  14293. InternalTimer(gettimeofday() + 5, "EnOcean_helperClear", \%functionHash, 0);
  14294. }
  14295. return;
  14296. }
  14297. #
  14298. sub EnOcean_helperClear($) {
  14299. my ($functionHash) = @_;
  14300. my $function = $functionHash->{function};
  14301. my $hash = $functionHash->{hash};
  14302. delete $hash->{helper}{$function};
  14303. return;
  14304. }
  14305. #
  14306. sub EnOcean_cdmClearRemoteWait($) {
  14307. my ($functionHash) = @_;
  14308. my $hash = $functionHash->{hash};
  14309. my $param = $functionHash->{param};
  14310. delete $hash->{IODev}{helper}{remoteAnswerWait}{$param}{hash};
  14311. #Log3 $hash->{NAME}, 3, "EnOcean $hash->{NAME} EnOcean_cdmClearRemoteWait executed.";
  14312. return;
  14313. }
  14314. #
  14315. sub EnOcean_cdmClearHashVal($) {
  14316. my ($functionHash) = @_;
  14317. my $hash = $functionHash->{hash};
  14318. my $param = $functionHash->{param};
  14319. delete $hash->{$param};
  14320. #Log3 $hash->{NAME}, 3, "EnOcean $hash->{NAME} EnOcean_cdmClearHashVal executed.";
  14321. return;
  14322. }
  14323. #
  14324. sub EnOcean_CommandDelete($) {
  14325. my ($functionHash) = @_;
  14326. my $deleteDevice = $functionHash->{deleteDevice};
  14327. my $function = $functionHash->{function};
  14328. my $hash = $functionHash->{hash};
  14329. my $name = $hash->{NAME};
  14330. my $oldDevice = $functionHash->{oldDevice};
  14331. CommandDelete(undef, $deleteDevice);
  14332. if (defined $oldDevice) {
  14333. Log3 $name, 2, "EnOcean $name: $oldDevice renamed to $deleteDevice";
  14334. CommandRename(undef, "$oldDevice $deleteDevice");
  14335. CommandSave(undef, undef);
  14336. } else {
  14337. Log3 $name, 2, "EnOcean $name: $deleteDevice deleted";
  14338. CommandSave(undef, undef);
  14339. }
  14340. return;
  14341. }
  14342. #
  14343. sub EnOcean_convBitToHex($) {
  14344. # convert bit string to hex string
  14345. my ($bitStr) = @_;
  14346. my $hexStr = '';
  14347. while(length($bitStr) > 0) {
  14348. $bitStr =~ m/^(.*)(.{8})$/;
  14349. $bitStr = $1;
  14350. $hexStr = unpack('H2', pack('B8', $2)) . $hexStr;
  14351. }
  14352. return uc($hexStr);
  14353. }
  14354. #
  14355. sub EnOcean_convHexToBit($) {
  14356. # convert unsign hex string to bit string
  14357. my ($hexstr) = @_;
  14358. my $bitstr = '';
  14359. while (length($hexstr) > 0) {
  14360. $hexstr =~ m/^(.*)(..)$/;
  14361. $hexstr = $1;
  14362. $bitstr = unpack('B8', pack('H2', $2)) . $bitstr;
  14363. }
  14364. return $bitstr;
  14365. }
  14366. #
  14367. sub EnOcean_convIntToBit($$) {
  14368. # convert unsign number to bitstring
  14369. my ($data, $resolution) = @_;
  14370. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr input: $data";
  14371. if ($data > 0xFFFF) {
  14372. # unsigned long (32 bit)
  14373. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack L: " . pack('L', $data);
  14374. #$data = unpack('B32', pack('L', $data));
  14375. $data = unpack('B32', $data);
  14376. } elsif ($data > 0xFF) {
  14377. # unsigned short (16 bit)
  14378. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack S: " . pack('S', $data);
  14379. #$data = '0' x 16 . unpack('B16', pack('S', $data));
  14380. $data = '0' x 16 . unpack('B16', $data);
  14381. } else {
  14382. # unsigned char (8 bit)
  14383. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack C: " . pack('C', $data);
  14384. $data = '0' x 24 . unpack('B8', pack('C', $data));
  14385. }
  14386. Log3 undef, 3, "EnOcean EnOcean_convIntToBitstr pack B32: " . $data;
  14387. $data = substr($data, 32 - $resolution);
  14388. return $data;
  14389. }
  14390. sub EnOcean_gpConvSelDataToSndData($$$$) {
  14391. # Generic Profiles, make selective data in hex
  14392. my ($header, $channel, $resolution, $data) = @_;
  14393. my $resolutionPattern = '%04B%06B%0' . $resolution . 'B';
  14394. $data = sprintf "$resolutionPattern", $header, $channel, $data;
  14395. if (($resolution + 10) % 8) {
  14396. # fill with trailing zeroes to x bytes
  14397. $data = $data . '0' x (8 - (10 + $resolution) % 8);
  14398. }
  14399. #Log3 undef, 3, "EnOcean EnOcean_gpConvSelDataToSndData header: $header channel: $channel data: $data";
  14400. $data = EnOcean_convBitToHex($data);
  14401. #Log3 undef, 3, "EnOcean EnOcean_gpConvSelDataToSndData header: $header channel: $channel data: $data";
  14402. return $data;
  14403. }
  14404. #
  14405. sub EnOcean_gpConvDataToValue($$$$$) {
  14406. # Generic Profiles, convert data to value
  14407. my ($ctrl, $hash, $channel, $data, $dataDescr) = @_;
  14408. my $name = $hash->{NAME};
  14409. my ($err, $logLevel, $msg, $readingFormat, $readingType, $readingUnit, $readingValue, $valueType) =
  14410. (undef, 5, 'ok', '%d', 'data', 'N/A', $data, 'value');
  14411. my @channelTypeList = ("teachIn", "data", "flag", "enum");
  14412. my @signalTypeList;
  14413. my @valueTypeList = ("res", "value", "setpointAbs", "setpointRel");
  14414. # extract channel definition
  14415. my ($channelName, $channelDir, $channelType, $signalType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax);
  14416. ($channelName, $channelDir, $channelType, $signalType, $valueType, $resolution, $engMin, $scalingMin, $engMax, $scalingMax) =
  14417. split(':', $dataDescr);
  14418. my $readingName = sprintf('%02d', $channel) . '-' . $channelName;
  14419. $readingType = $channelTypeList[$channelType];
  14420. $valueType = $valueTypeList[$valueType];
  14421. if ($channelType == 3) {
  14422. # enumeration
  14423. if (defined $EnO_gpValueEnum{$signalType}{enum}{$data}) {
  14424. $readingValue = $EnO_gpValueEnum{$signalType}{enum}{$data};
  14425. $readingFormat = '%s';
  14426. }
  14427. } elsif ($channelType == 2) {
  14428. # flag
  14429. if (defined $EnO_gpValueFlag{$signalType}{flag}{$data}) {
  14430. $readingValue = $EnO_gpValueFlag{$signalType}{flag}{$data};
  14431. $readingFormat = '%s';
  14432. }
  14433. } elsif ($channelType == 1) {
  14434. # data
  14435. if (defined $EnO_gpValueData{$signalType}{unit}) {
  14436. $readingUnit = $EnO_gpValueData{$signalType}{unit};
  14437. }
  14438. my @decimalDigits = (0, 1, 1, 2, 2, 2, 3, 4 , 4, 5, 7, 8, 10);
  14439. $readingValue = $data / 2**$EnO_resolution[$resolution] *
  14440. ($engMax * $EnO_scaling[$scalingMax] - $engMin * $EnO_scaling[$scalingMin]) + $engMin * $EnO_scaling[$scalingMin];
  14441. if ($readingValue =~ m/^[+-]?\d+$/) {
  14442. } elsif ($readingValue < 1000) {
  14443. $readingFormat = '%0.' . ($decimalDigits[$resolution] - 1) . 'f';
  14444. } else {
  14445. $readingFormat = '%.' . ($decimalDigits[$resolution] - 1) . 'g';
  14446. }
  14447. } else {
  14448. # teach-in info ... not used
  14449. my @valueList = ("res", "channelsDescription", "productID");
  14450. if (defined $valueList[$signalType]) {
  14451. $readingValue = $valueList[$signalType];
  14452. $readingFormat = '%s';
  14453. }
  14454. }
  14455. return ($err, $logLevel, $msg, $readingFormat, $readingName, $readingType, $readingUnit, $readingValue, $valueType);
  14456. }
  14457. # Parse Secure Teach-In Telegrams
  14458. sub EnOcean_sec_parseTeachIn($$$$) {
  14459. my ($hash, $telegram, $subDef, $destinationID) = @_;
  14460. my $name = $hash->{NAME};
  14461. my ($err, $response, $logLevel);
  14462. my $rlc; # Rolling code
  14463. my $key1; # First part of private key
  14464. my $key2; # Second part of private key
  14465. # Extract byte fields from telegram
  14466. # TEACH_IN_INFO, SLF, RLC/KEY/variable
  14467. $telegram =~ /^(..)(..)(.*)/; # TODO Parse error handling?
  14468. my $teach_bin = unpack('B8',pack('H2', $1)); # Parse as ASCII HEX, unpack to bitstring
  14469. my $slf_bin = unpack('B8',pack('H2', $2)); # Parse as ASCII HEX, unpack to bitstring
  14470. my $crypt = $3;
  14471. # Extract bit fields from teach-in info field
  14472. # IDX, CNT, PSK, TYPE, INFO
  14473. $teach_bin =~ /(..)(..)(.)(.)(..)/; # TODO Parse error handling?
  14474. my $idx = unpack('C',pack('B8', '000000'.$1)); # Padd to byte, parse as unsigned char
  14475. my $cnt = unpack('C',pack('B8', '000000'.$2)); # Padd to byte, parse as unsigned char
  14476. my $psk = $3;
  14477. my $type = $4;
  14478. my $info = unpack('C',pack('B8', '000000'.$5)); # Padd to byte, parse as unsigned char
  14479. # Extract bit fields from SLF field
  14480. # RLC_ALGO, RLC_TX, MAC_ALGO, DATA_ENC
  14481. $slf_bin =~ /(..)(.)(..)(...)/; # TODO Parse error handling?
  14482. my $rlc_algo = unpack('C',pack('B8', '000000'.$1)); # Padd to byte, parse as unsigned char
  14483. my $rlc_tx = $2;
  14484. my $mac_algo = unpack('C',pack('B8', '000000'.$3)); # Padd to byte, parse as unsigned char
  14485. my $data_enc = unpack('C',pack('B8', '00000'.$4)); # Padd to byte, parse as unsigned char
  14486. # The teach-in information is split in two telegrams due to the ERP1 limitations on telegram length
  14487. # So we should get a telegram with index 0 and count 2 with the first half of the infos needed
  14488. if ($idx == 0 && $cnt == 2) {
  14489. # First part of the teach in message
  14490. # Decode teach in type
  14491. if ($type == 0) {
  14492. # 1BS, 4BS, UTE or GP teach-in expected
  14493. if ($info == 0) {
  14494. $attr{$name}{comMode} = "uniDir";
  14495. $attr{$name}{secMode} = "rcv";
  14496. } else {
  14497. $attr{$name}{comMode} = "biDir";
  14498. $attr{$name}{secMode} = "biDir";
  14499. }
  14500. $hash->{helper}{teachInWait} = "STE";
  14501. } else {
  14502. # switch teach-in
  14503. $attr{$name}{teachMethod} = 'STE';
  14504. if ($info == 0) {
  14505. $attr{$name}{comMode} = "uniDir";
  14506. $attr{$name}{eep} = "D2-03-00";
  14507. $attr{$name}{manufID} = "7FF";
  14508. $attr{$name}{secMode} = "rcv";
  14509. foreach my $attrCntr (keys %{$EnO_eepConfig{"D2.03.00"}{attr}}) {
  14510. $attr{$name}{$attrCntr} = $EnO_eepConfig{"D2.03.00"}{attr}{$attrCntr};
  14511. }
  14512. readingsSingleUpdate($hash, "teach", "STE teach-in accepted EEP D2-03-00 Manufacturer: " . $EnO_manuf{"7FF"}, 1);
  14513. Log3 $name, 2, "EnOcean $name STE teach-in accepted EEP D2-03-00 Rocker A Manufacturer: " . $EnO_manuf{"7FF"};
  14514. } else {
  14515. $attr{$name}{comMode} = "uniDir";
  14516. $attr{$name}{eep} = "D2-03-00";
  14517. $attr{$name}{manufID} = "7FF";
  14518. $attr{$name}{secMode} = "rcv";
  14519. foreach my $attrCntr (keys %{$EnO_eepConfig{"D2.03.00"}{attr}}) {
  14520. $attr{$name}{$attrCntr} = $EnO_eepConfig{"D2.03.00"}{attr}{$attrCntr};
  14521. }
  14522. readingsSingleUpdate($hash, "teach", "STE teach-in accepted EEP D2-03-00 Manufacturer: " . $EnO_manuf{"7FF"}, 1);
  14523. Log3 $name, 2, "EnOcean $name STE teach-in accepted EEP D2-03-00 Rocker B Manufacturer: " . $EnO_manuf{"7FF"};
  14524. }
  14525. }
  14526. # Decode RLC algorithm and extract RLC and private key (only first part most likely)
  14527. if ($rlc_algo == 0) {
  14528. # No RLC used in telegram or internally in memory, use case untested
  14529. return ("Secure modes without RLC not tested or supported", undef);
  14530. } elsif ($rlc_algo == 1) {
  14531. # "RLC= 2-byte long. RLC algorithm consists on incrementing in +1 the previous RLC value
  14532. # Extract RLC and KEY fields from data trailing SLF field
  14533. # RLC, KEY, ID, STATUS
  14534. $crypt =~ /^(....)(.*)$/;
  14535. $rlc = $1;
  14536. $key1 = $2;
  14537. #print "RLC: $rlc\n";
  14538. #print "Part 1 of KEY: $key1\n";
  14539. # Store in device hash
  14540. $attr{$name}{rlcAlgo} = '2++';
  14541. readingsSingleUpdate($hash, ".rlcRcv", $rlc, 0);
  14542. # storing backup copy
  14543. $attr{$name}{rlcRcv} = $rlc;
  14544. $attr{$name}{keyRcv} = $key1;
  14545. } elsif ($rlc_algo == 2) {
  14546. # RLC= 3-byte long. RLC algorithm consists on incrementing in +1 the previous RLC value
  14547. # Extract RLC and KEY fields from data trailing SLF field
  14548. # RLC, KEY, ID, STATUS
  14549. $crypt =~ /^(......)(.*)$/;
  14550. $rlc = $1;
  14551. $key1 = $2;
  14552. #print "RLC: $rlc\n";
  14553. #print "Part 1 of KEY: $key1\n";
  14554. # Store in device hash
  14555. $attr{$name}{rlcAlgo} = '3++';
  14556. readingsSingleUpdate($hash, ".rlcRcv", $rlc, 0);
  14557. # storing backup copy
  14558. $attr{$name}{rlcRcv} = $rlc;
  14559. $attr{$name}{keyRcv} = $key1;
  14560. } else {
  14561. # Undefined RLC algorithm
  14562. return ("Undefined RLC algorithm $rlc_algo", undef);
  14563. }
  14564. # RLC Transmission
  14565. if ($rlc_tx == 0 ) {
  14566. # Secure operation mode telegrams do not contain RLC, we store and track it ourself
  14567. $attr{$name}{rlcTX} = 'false';
  14568. } else {
  14569. # Secure operation mode messages contain RLC, CAUTION untested
  14570. $attr{$name}{rlcTX} = 'true';
  14571. }
  14572. # Decode MAC Algorithm
  14573. if ($mac_algo == 0) {
  14574. # No MAC included in the secure telegram
  14575. # Doesn't make sense for RLC senders like the PTM215, as we can't verify the RLC then...
  14576. #$attr{$name}{macAlgo} = 'no';
  14577. return ("Secure mode without MAC algorithm unsupported", undef);
  14578. } elsif ($mac_algo == 1) {
  14579. # CMAC is a 3-byte-long code
  14580. $attr{$name}{macAlgo} = '3';
  14581. } elsif ($mac_algo == 2) {
  14582. # MAC is a 4-byte-long code
  14583. $attr{$name}{macAlgo} = '4';
  14584. } else {
  14585. # Undefined MAC algorith;
  14586. # Nothing we can do either...
  14587. #$attr{$name}{macAlgo} = 'no';
  14588. return ("Undefined MAC algorithm $mac_algo", undef);
  14589. }
  14590. # Decode data encryption algorithm
  14591. if ($data_enc == 0) {
  14592. # Data not encrypted? Right now we will handle this like an error, concrete use case untested
  14593. #$attr{$name}{secLevel} = 'encapsulation';
  14594. return ("Secure mode message without data encryption unsupported", undef);
  14595. } elsif ($data_enc == 1) {
  14596. # Unspecified
  14597. return ("Undefined data encryption algorithm $data_enc", undef);
  14598. } elsif ($data_enc == 2) {
  14599. # Unspecified
  14600. return ("Undefined data encryption algorithm $data_enc", undef);
  14601. } elsif ($data_enc == 3) {
  14602. # Data will be encrypted/decrypted XORing with a string obtained from a AES128 encryption
  14603. $attr{$name}{dataEnc} = 'VAES';
  14604. $attr{$name}{secLevel} = 'encryption';
  14605. } elsif ($data_enc == 4) {
  14606. # Data will be encrypted/decrypted using the AES128 algorithm in CBC mode
  14607. # Might be used in the future right now untested
  14608. #$attr{$name}{dataEnc} = 'AES-CBC';
  14609. #$attr{$name}{secLevel} = 'encryption';
  14610. return ("Secure mode message with AES-CBC data encryption unsupported", undef);
  14611. } else {
  14612. # Something went horribly wrong
  14613. return ("Could not parse data encryption information, $data_enc", undef);
  14614. }
  14615. $hash->{helper}{teachInSTE} = $cnt - 1;
  14616. # Ok we got a lots of infos and the first part of the private key
  14617. return (undef, "part1: $name");
  14618. } elsif ($idx == 1 && exists($hash->{helper}{teachInSTE})) {
  14619. # Second part of the teach-in telegrams
  14620. # Extract byte fields from telegram
  14621. # Don't care about info fields, KEY, ID, don't care about status
  14622. $telegram =~ /^..(.*)$/; # TODO Parse error handling?
  14623. $key2 = $1;
  14624. # We already should have gathered the infos from the first teach-in telegram
  14625. if (!defined($attr{$name}{keyRcv})) {
  14626. # We have missed the first telegram
  14627. return ("Missing first teach-in telegram", undef);
  14628. }
  14629. # Append second part of private key to first part of private key
  14630. $attr{$name}{keyRcv} .= $key2;
  14631. if ($attr{$name}{secMode} eq "biDir") {
  14632. # bidirectional secure teach-in
  14633. if (!defined $subDef) {
  14634. $subDef = EnOcean_CheckSenderID("getNextID", $defs{$name}{IODev}{NAME}, "00000000");
  14635. $attr{$name}{subDef} = $subDef;
  14636. }
  14637. ($err, $response, $logLevel) = EnOcean_sec_createTeachIn(undef, $hash, $attr{$name}{comMode},
  14638. $attr{$name}{dataEnc}, $attr{$name}{eep},
  14639. $attr{$name}{macAlgo}, $attr{$name}{rlcAlgo},
  14640. $attr{$name}{rlcTX}, $attr{$name}{secLevel},
  14641. $subDef, $destinationID);
  14642. if ($err) {
  14643. Log3 $name, $logLevel, "EnOcean $name Error: $err";
  14644. return $err;
  14645. } else {
  14646. Log3 $name, $logLevel, "EnOcean $name $response";
  14647. }
  14648. }
  14649. delete $hash->{helper}{teachInSTE};
  14650. return (undef, "part2: $name");
  14651. }
  14652. # Sequence error?
  14653. return ("teach-in sequence error IDC: $idx CNT: $cnt", undef);
  14654. }
  14655. # Do VAES decyrption
  14656. # All parameters need to be passed as byte strings
  14657. #
  14658. # Parameter 1: Current rolling code, 16 bytes
  14659. # Parameter 2: Private key, 16bytes
  14660. # Paremeter 3: Encrypted data, 16bytes
  14661. #
  14662. # Returns: Decrypted data, 16 bytes
  14663. #
  14664. # Decryption of more than 16bytes of data is currently unsupported
  14665. #
  14666. sub EnOcean_sec_decodeVAES($$$) {
  14667. my $rlc = $_[0];
  14668. my $private_key = $_[1];
  14669. my $data_enc = $_[2];
  14670. # Public key according to EnOcean Security specification
  14671. my $public_key = pack('H32', '3410de8f1aba3eff9f5a117172eacabd');
  14672. # Input for VAES
  14673. my $aes_in = $public_key ^ $rlc;
  14674. #print "--\n";
  14675. #print "Public Key ".unpack('H32', $public_key)."\n";
  14676. #print "RLC ".unpack('H32', $rlc)."\n";
  14677. #print "AES input ".unpack('H32', $aes_in)."\n";
  14678. #print "--\n";
  14679. #print "Private Key ".unpack('H32', $private_key)."\n";
  14680. my $cipher = Crypt::Rijndael->new( $private_key );
  14681. my $aes_out = $cipher->encrypt($aes_in);
  14682. #print "AES output ".unpack('H32', $aes_out)."\n";
  14683. #print "Data_enc: ".unpack('H32', $data_enc)."\n";
  14684. my $data_dec = $data_enc ^ $aes_out;
  14685. #print "Data_dec: ".unpack('H32', $data_dec)."\n";
  14686. return $data_dec;
  14687. }
  14688. # Returns current RLC in hex format and increments the stored RLC
  14689. # Checks the boundaries of the RLC for roll-over
  14690. #
  14691. # Parameter 1: Sender ID in hexadecimal format for lookup in receivers hash
  14692. #
  14693. # Affects: receivers hash
  14694. #
  14695. # Returns: RLC in hexadecimal format
  14696. #
  14697. sub EnOcean_sec_getRLC($$) {
  14698. my $hash = $_[0];
  14699. my $rlcVar = $_[1];
  14700. my $name = $hash->{NAME};
  14701. # Fetch newest RLC from receiver hash
  14702. my $old_rlc = ReadingsVal($name, "." . $rlcVar, $attr{$name}{$rlcVar});
  14703. if (hex($old_rlc) < hex($attr{$name}{$rlcVar})) {
  14704. $old_rlc = $attr{$name}{$rlcVar};
  14705. }
  14706. #print "RLC old: $old_rlc\n";
  14707. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC old: $old_rlc";
  14708. # Advance RLC by one
  14709. my $new_rlc = hex($old_rlc) + 1;
  14710. # Boundary check
  14711. if ($attr{$name}{rlcAlgo} eq '2++') {
  14712. if ($new_rlc > 65535) {
  14713. #print "RLC rollover\n";
  14714. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC rollover";
  14715. $new_rlc = 0;
  14716. $attr{$name}{$rlcVar} = "0000";
  14717. EnOcean_CommandSave(undef, undef);
  14718. }
  14719. readingsSingleUpdate($hash, "." . $rlcVar, uc(unpack('H4',pack('n', $new_rlc))), 0);
  14720. $attr{$name}{$rlcVar} = uc(unpack('H4',pack('n', $new_rlc)));
  14721. } elsif ($attr{$name}{rlcAlgo} eq '3++') {
  14722. if ($new_rlc > 16777215) {
  14723. #print "RLC rollover\n";
  14724. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC rollover";
  14725. $new_rlc = 0;
  14726. $attr{$name}{$rlcVar} = "000000";
  14727. EnOcean_CommandSave(undef, undef);
  14728. }
  14729. readingsSingleUpdate($hash, "." . $rlcVar, uc(unpack('H6',pack('N', $new_rlc))), 0);
  14730. $attr{$name}{$rlcVar} = uc(unpack('H6',pack('N', $new_rlc)));
  14731. }
  14732. #print "RLC new: ".$attr{$name}{rlc}."\n";
  14733. Log3 $name, 5, "EnOcean $name EnOcean_sec_getRLC RLC new: ". $attr{$name}{$rlcVar};
  14734. return $old_rlc;
  14735. }
  14736. # Generate MAC of data
  14737. #
  14738. # Parameter 1: private key as byte string, 16bytes
  14739. # Parameter 2: data fro which mac should be calculated in hexadecimal format, len variable
  14740. # Parameter 3: length of MAC to be generated in bytes
  14741. #
  14742. # Returns: MAC in hexadecimal format
  14743. #
  14744. # This function currently supports data with lentgh of less then 16bytes,
  14745. # MAC for longer data is untested but specified
  14746. #
  14747. sub EnOcean_sec_generateMAC($$$) {
  14748. my $private_key = $_[0];
  14749. my $data = $_[1];
  14750. my $cmac_len = $_[2];
  14751. #print "Calculating MAC for data $data\n";
  14752. Log3 undef, 5, "EnOcean_sec_generateMAC Calculating MAC for data $data";
  14753. Log3 undef, 5, "EnOcean_sec_generateMAC private key ".unpack('H32', $private_key);
  14754. # Pack data to 16byte byte string, padd with 10..0 binary
  14755. my $data_expanded = pack('H32', $data.'80');
  14756. #print "Exp. data ".unpack('H32', $data_expanded)."\n";
  14757. # Constants according to specification
  14758. my $const_zero = pack('H32','00');
  14759. my $const_rb = pack('H32', '00000000000000000000000000000087');
  14760. # Encrypt zero data with private key to get L
  14761. my $cipher = Crypt::Rijndael->new($private_key);
  14762. my $l = $cipher->encrypt($const_zero);
  14763. #print "L ".unpack('H32', $l)."\n";
  14764. #print "L ".unpack('B128', $l)."\n";
  14765. # Expand L to 128bit string
  14766. my $l_bit = unpack('B128', $l);
  14767. # K1 and K2 stored as 128bit string
  14768. my $k1_bit;
  14769. my $k2_bit;
  14770. # K1 and K2 as binary
  14771. my $k1;
  14772. my $k2;
  14773. # Store L << 1 in K1
  14774. $l_bit =~ /^.(.{127})/;
  14775. $k1_bit = $1.'0';
  14776. $k1 = pack('B128', $k1_bit);
  14777. # If MSB of L == 1, K1 = K1 XOR const_Rb
  14778. if($l_bit =~ m/^1/) {
  14779. #print "MSB of L is set\n";
  14780. $k1 = $k1 ^ $const_rb;
  14781. $k1_bit = unpack('B128', $k1);
  14782. } else {
  14783. #print "MSB of L is unset\n";
  14784. }
  14785. # Store K1 << 1 in K2
  14786. $k1_bit =~ /^.(.{127})/;
  14787. $k2_bit = $1.'0';
  14788. $k2 = pack('B128', $k2_bit);
  14789. # If MSB of K1 == 1, K2 = K2 XOR const_Rb
  14790. if($k1_bit =~ m/^1/) {
  14791. #print "MSB of K1 is set\n";
  14792. $k2 = $k2 ^ $const_rb;
  14793. } else {
  14794. #print "MSB of K1 is unset\n";
  14795. }
  14796. # XOR data with K2
  14797. $data_expanded ^= $k2;
  14798. # Encrypt data
  14799. my $cmac = $cipher->encrypt($data_expanded);
  14800. #print "CMAC ".unpack('H32', $cmac)."\n";
  14801. Log3 undef, 5, "EnOcean_sec_generateMAC CMAC ".unpack('H32', $cmac);
  14802. # Extract specified len of MAC
  14803. my $cmac_pattern = '^(.{'.($cmac_len * 2).'})';
  14804. unpack('H32', $cmac) =~ /$cmac_pattern/;
  14805. Log3 undef, 5, "EnOcean_sec_generateMAC cutted CMAC ".unpack('H32', $1);
  14806. # Return MAC in hexadecimal format
  14807. return uc($1);
  14808. }
  14809. # Verify (MAC) and decode/decrypt secure mode message
  14810. #
  14811. # Parameter 1: content of radio telegram in hexadecimal format
  14812. #
  14813. # Returns: "ERROR-" + error description, "OK-" + EEP D2-03-00 telegram in hexadecimal format
  14814. #
  14815. # Right now we only decode PTM215 telegrams which are transmitted as RORG 30 and without
  14816. # encapsulation. Encapsulation of other telegrams is possible and specified but untested due to the
  14817. # lack of hardware suporting this.
  14818. #
  14819. sub EnOcean_sec_convertToNonsecure($$$) {
  14820. my ($hash, $rorg, $crypt_data) = @_;
  14821. my $name = $hash->{NAME};
  14822. if ($cryptFunc == 0) {
  14823. return ("Cryptographic functions are not available", undef, undef);
  14824. }
  14825. my $private_key;
  14826. # Prefix of pattern to extract the different cryptographic infos
  14827. my $crypt_pattern = "^(.*)";;
  14828. # Flags and infos for fields to expect
  14829. my $expect_rlc = 0;
  14830. my $expect_mac = 0;
  14831. my $mac_len;
  14832. my $expect_enc = 0;
  14833. # Check if RLC is transmitted and when, which length to expect
  14834. if($attr{$name}{rlcTX} eq 'true') {
  14835. # Message should contain RLC
  14836. if ($attr{$name}{rlcAlgo} eq '2++') {
  14837. $crypt_pattern .= "(....)";
  14838. $expect_rlc = 1;
  14839. } elsif ($attr{$name}{rlcAlgo} eq '3++') {
  14840. $crypt_pattern .= "(......)";
  14841. $expect_rlc = 1;
  14842. } else {
  14843. # RLC_TX but no info on RLC length
  14844. return ("RLC_TX and RLC_ALGO inconsistent", undef, undef);
  14845. }
  14846. }
  14847. # Check what length of MAC to expect
  14848. if($attr{$name}{macAlgo} eq '3') {
  14849. $crypt_pattern .= "(......)";
  14850. $mac_len = 3;
  14851. $expect_mac = 1;
  14852. } elsif ($attr{$name}{macAlgo} eq '4') {
  14853. $crypt_pattern .= "(........)";
  14854. $mac_len = 4;
  14855. $expect_mac = 1;
  14856. } else {
  14857. # According to the specification it's possible to transmit no MAC, bt we don't implement this for now
  14858. return ("Secure mode messages without MAC unsupported", undef, undef);
  14859. }
  14860. # Suffix for crypt pattern
  14861. $crypt_pattern .= '$';
  14862. # Extract byte fields from message payload
  14863. $crypt_data =~ /$crypt_pattern/;
  14864. my $data_enc = $1;
  14865. my $dataLength = length($data_enc);
  14866. return ("Telegrams with a length of more than 16 bytes are not supported", undef, undef) if ($dataLength > 32);
  14867. my $rlc;
  14868. my $mac;
  14869. if ($expect_rlc == 1 && $expect_mac == 1) {
  14870. $rlc = $2;
  14871. $mac = $3;
  14872. } elsif ($expect_rlc == 0 && $expect_mac == 1) {
  14873. $mac = $2;
  14874. }
  14875. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure RORG: $rorg DATA_ENC: $data_enc";
  14876. if ($expect_rlc == 1) {
  14877. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure RLC: $rlc";
  14878. };
  14879. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure MAC: $mac";
  14880. # TODO RLC could be transmitted with data, could not test this
  14881. #if(!defined($rlc)) {
  14882. # print "No RLC in message, using stored value\n";
  14883. # $rlc = getRLC($senderID);
  14884. #}
  14885. # Maximum RLC search window is 128
  14886. foreach my $rlc_window (0..128) {
  14887. #print "Trying RLC offset $rlc_window\n";
  14888. # Fetch stored RLC
  14889. $rlc = EnOcean_sec_getRLC($hash, "rlcRcv");
  14890. # Fetch private Key for VAES
  14891. if ($attr{$name}{keyRcv} =~ /[\dA-F]{32}/) {
  14892. $private_key = pack('H32',$attr{$name}{keyRcv});
  14893. } else {
  14894. return ("private key wrong, please teach-in the device new", undef, undef);
  14895. }
  14896. # Generate and check MAC over RORG+DATA+RLC fields
  14897. if ($mac eq EnOcean_sec_generateMAC($private_key, $rorg.$data_enc.$rlc, $mac_len)) {
  14898. #print "RLC verfified\n";
  14899. # Expand RLC to 16byte
  14900. my $rlc_expanded = pack('H32',$rlc);
  14901. # Expand data to 16byte
  14902. my $data_expanded = pack('H32',$data_enc);
  14903. # Decode data using VAES
  14904. my $data_dec = EnOcean_sec_decodeVAES($rlc_expanded, $private_key, $data_expanded);
  14905. my $data_end = unpack('H32', $data_dec);
  14906. if ($rorg eq '30') {
  14907. # Extract one nibble of data
  14908. $data_end =~ /^.(.)/;
  14909. return (undef, '32', "0" . uc($1));
  14910. } else {
  14911. $dataLength -= 2;
  14912. $data_end =~ /^(..)(.{$dataLength})/;
  14913. Log3 $name, 5, "EnOcean $name EnOcean_sec_convertToNonsecure RORG: " . uc($1) . " DATA: " . uc($2);
  14914. return (undef, uc($1), uc($2));
  14915. }
  14916. }
  14917. }
  14918. # Couldn't verify or decrypt message in RLC window
  14919. return ("Can't verify or decrypt telegram", undef, undef);
  14920. }
  14921. #
  14922. sub EnOcean_sec_createTeachIn($$$$$$$$$$$)
  14923. {
  14924. my ($ctrl, $hash, $comMode, $dataEnc, $eep, $macAlgo, $rlcAlgo, $rlcTX, $secLevel, $subDef, $destinationID) = @_;
  14925. my $name = $hash->{NAME};
  14926. my ($data, $err, $response, $loglevel);
  14927. # THIS IS A BASIC IMPLEMENTATION WITH HARDCODED VALUES FOR
  14928. # THE SECURITY PARAMETERS, WILL BE CUSTOMIZABLE IN FUTURE
  14929. if ($cryptFunc == 0) {
  14930. return ("Cryptographic functions are not available", undef, 2);
  14931. }
  14932. # generate random private key
  14933. my $pKey;
  14934. for (my $i = 1; $i < 5; $i++) {
  14935. $pKey .= uc(unpack('H8', pack('L', makerandom(Size => 32, Strength => 1))));
  14936. }
  14937. $attr{$name}{keySnd} = AttrVal($name, "keySnd", $pKey);
  14938. #generate random rlc, save to fhem.cfg and update readings
  14939. my $rlc = ReadingsVal($name, ".rlcSnd", uc(unpack('H4', pack('n', makerandom(Size => 16, Strength => 1)))));
  14940. readingsSingleUpdate($hash, ".rlcSnd", $rlc, 0);
  14941. $attr{$name}{rlcSnd} = $rlc;
  14942. $attr{$name}{comMode} = AttrVal($name, "comMode", $comMode);
  14943. $attr{$name}{dataEnc} = AttrVal($name, "dataEnc", $dataEnc);
  14944. $attr{$name}{eep} = $eep;
  14945. $attr{$name}{macAlgo} = AttrVal($name, "macAlgo", $macAlgo);
  14946. $attr{$name}{manufID} = "7FF";
  14947. $attr{$name}{rlcAlgo} = AttrVal($name, "rlcAlgo", $rlcAlgo);
  14948. $attr{$name}{rlcTX} = AttrVal($name, "rlcTX", $rlcTX);
  14949. $attr{$name}{secLevel} = AttrVal($name, "secLevel", $secLevel);
  14950. if (AttrVal($name, "secMode", "") =~ m/^rcv|bidir$/) {
  14951. $attr{$name}{secMode} = "biDir";
  14952. } else {
  14953. $attr{$name}{secMode} = "snd";
  14954. }
  14955. # prepare 1st telegram
  14956. #RORG = 35, TEACH_IN_INFO_0, SLF, RLC, KEY, ID, STATUS as defined in Security_of_EnOcean_Radio_Networks.pdf page 17
  14957. #set TEACH_IN_INFO = 25 -> 0001.0101 -> IDX =0, CNT = 2, PSK = 0, TYPE = 1, INFO = 1
  14958. #set SLF = 4B -> 0100.1011 -> RLC_ALGO=16bit, RLC-TX=0, MAC-ALGO = AES3BYTE, DATA_ENC = VAES128
  14959. #save the fixed security parameters to fhem.cfg
  14960. #get first 5 bytes of private key
  14961. #data 1: 25 4B r1 r2 k1 k2 k3 k4 k5
  14962. $data = "254B" . $rlc . substr($attr{$name}{keySnd}, 0, 5*2);
  14963. EnOcean_SndRadio(undef, $hash, 1, "35", $data, $subDef, "00", $destinationID);
  14964. # prepare 2nd telegram
  14965. #RORG = 35, TEACH_IN_INFO_1, KEY, ID, STATUS as defined in Security_of_EnOcean_Radio_Networks.pdf page 17
  14966. #set TEACH_IN_INFO = 40 -> 0100.0000 -> IDX =1, CNT = 0, PSK = 0, TYPE = 0, INFO = 0
  14967. #get 2nd 11 bytes of private key
  14968. #data 2: 40 k6 k7 k8 k9 k10 k11 k12 k13 k14 k15 k16
  14969. $data = "40" . substr($attr{$name}{keySnd}, 10, 11*2);
  14970. EnOcean_SndRadio(undef, $hash, 1, "35", $data, $subDef, "00", $destinationID);
  14971. return (undef, "secure teach-in", 2);
  14972. }
  14973. #
  14974. sub EnOcean_sec_convertToSecure($$$$)
  14975. {
  14976. my ($hash, $packetType, $rorg, $data) = @_;
  14977. my ($err, $response, $loglevel);
  14978. my $name = $hash->{NAME};
  14979. my $secLevel = AttrVal($name, "secLevel", "off");
  14980. # encryption needed?
  14981. return ($err, $rorg, $data, $response, 5) if ($rorg =~ m/^F6|35$/ || $secLevel !~ m/^encapsulation|encryption$/);
  14982. return ("Cryptographic functions are not available", undef, undef, $response, 2) if ($cryptFunc == 0);
  14983. my $dataEnc = AttrVal($name, "dataEnc", undef);
  14984. my $subType = AttrVal($name, "subType", "");
  14985. # subType specific actions
  14986. if ($subType eq "switch.00" || $subType eq "windowHandle.10") {
  14987. # securemode for D2-03-00 and D2-03-10
  14988. if (hex($data) > 15) {
  14989. return("wrong data byte", $rorg, $data, $response, 2);
  14990. }
  14991. # set rorg to secure telegram
  14992. $rorg = "30";
  14993. } else {
  14994. return("Cryptographic functions for $subType not available", $rorg, $data, $response, 2);
  14995. }
  14996. #Get and update RLC
  14997. my $rlc = EnOcean_sec_getRLC($hash, "rlcSnd");
  14998. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: Got actual RLC: $rlc";
  14999. #Get key of device
  15000. my $pKey = AttrVal($name, "keySnd", undef);
  15001. return("private key not defined", $rorg, $data, $response, 2) if (!defined $pKey);
  15002. $pKey = pack('H32', $pKey);
  15003. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: key: " . AttrVal($name, "keySnd", "");
  15004. #prepare data
  15005. my $rlc_expanded = pack('H32', $rlc);
  15006. my $data_expanded = pack('H32', $data);
  15007. my $data_dec;
  15008. if ($dataEnc eq "VAES") {
  15009. $data_dec = EnOcean_sec_decodeVAES($rlc_expanded, $pKey, $data_expanded);
  15010. } else {
  15011. return("Cryptographic functions not available", $rorg, $data, $response, 2);
  15012. }
  15013. my $data_end = unpack('H32', $data_dec);
  15014. #get the correct nibble
  15015. $data_end =~ /^.(.)/;
  15016. $data_end = uc("0$1");
  15017. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: Crypted Data: $data_end";
  15018. # calc MAC
  15019. my $macAlgo = AttrVal($name, "macAlgo", undef);
  15020. return("MAC Algorithm not defined", $rorg, $data, $response, 2) if (!defined $macAlgo);
  15021. my $mac = EnOcean_sec_generateMAC($pKey, $rorg . $data_end . $rlc, $macAlgo);
  15022. # combine message
  15023. $data = $data_end . uc($mac);
  15024. #Log3 $hash->{NAME}, 5, "EnOcean_sec_convertToSecure: Crypted Payload: $data";
  15025. return(undef, $rorg, $data, $response, 5);
  15026. }
  15027. #
  15028. sub
  15029. EnOcean_NumericSort
  15030. {
  15031. if ($a < $b) {
  15032. return -1;
  15033. } elsif ($a == $b) {
  15034. return 0;
  15035. } else {
  15036. return 1;
  15037. }
  15038. }
  15039. sub EnOcean_TimeDiff($)
  15040. {
  15041. my ($strTS) = @_;
  15042. if (defined $strTS) {
  15043. my $timeDiff = gettimeofday() - ($strTS eq "" ? gettimeofday() : time_str2num($strTS));
  15044. $timeDiff = 0 if ($timeDiff < 0);
  15045. return $timeDiff;
  15046. } else {
  15047. return 0;
  15048. }
  15049. }
  15050. # Undef
  15051. sub
  15052. EnOcean_Undef($$)
  15053. {
  15054. my ($hash, $name) = @_;
  15055. delete $hash->{helper};
  15056. delete $modules{EnOcean}{defptr}{uc($hash->{DEF})};
  15057. delete $modules{EnOcean}{defptr}{uc($attr{$name}{remoteID})} if (exists $attr{$name}{remoteID});
  15058. if (AttrVal($name, "remoteManagement", "off") eq "client") {
  15059. delete $hash->{RemoteClientUnlock};
  15060. my %functionHash = (hash => $hash, param => 'RemoteClientUnlock');
  15061. RemoveInternalTimer(\%functionHash);
  15062. }
  15063. return undef;
  15064. }
  15065. # Delete
  15066. sub
  15067. EnOcean_Delete($$)
  15068. {
  15069. my ($hash, $name) = @_;
  15070. my $logName = "FileLog_$name";
  15071. my ($count, $gplotFile, $logFile, $weblinkName, $weblinkHash);
  15072. Log3 $name, 2, "EnOcean $name deleted";
  15073. # delete FileLog device and log files
  15074. if (exists $defs{$logName}) {
  15075. $logFile = $defs{$logName}{logfile};
  15076. $logFile =~ /^(.*)($name).*\.(.*)$/;
  15077. $logFile = $1 . $2 . "*." . $3;
  15078. CommandDelete(undef, "FileLog_$name");
  15079. Log3 $name, 2, "EnOcean FileLog_$name deleted";
  15080. $count = unlink glob $logFile;
  15081. Log3 $name, 2, "EnOcean $logFile >> $count files deleted";
  15082. }
  15083. # delete SVG devices and gplot files
  15084. while (($weblinkName, $weblinkHash) = each(%defs)) {
  15085. if ($weblinkName =~ /^SVG_$name.*/) {
  15086. $gplotFile = "./www/gplot/" . $defs{$weblinkName}{GPLOTFILE} . "*.gplot";
  15087. CommandDelete(undef, $weblinkName);
  15088. Log3 $name, 2, "EnOcean $weblinkName deleted";
  15089. $count = unlink glob $gplotFile;
  15090. Log3 $name, 2, "EnOcean $gplotFile >> $count files deleted";
  15091. }
  15092. }
  15093. return undef;
  15094. }
  15095. 1;
  15096. =pod
  15097. =item device
  15098. =item summary EnOcean Gateway and Actor
  15099. =item summary_DE EnOcean Gateway und Aktor
  15100. =begin html
  15101. <a name="EnOcean"></a>
  15102. <h3>EnOcean</h3>
  15103. <ul><br>
  15104. <b>Quick Links</b>
  15105. <ul>
  15106. <li><a href="#EnOceanget">Get Commands</a></li>
  15107. <li><a href="#EnOceanset">Set Commands</a></li>
  15108. <li><a href="#EnOceanattr">Attributes</a></li>
  15109. <li><a href="#EnOceanevents">Generated Events</a></li>
  15110. </ul><br><br>
  15111. EnOcean devices are sold by numerous hardware vendors (e.g. Eltako, Peha, etc),
  15112. using the RF Protocol provided by the EnOcean Alliance.<br><br>
  15113. Depending on the function of the device an specific device profile is used, called
  15114. EnOcean Equipment Profile (EEP). The specific definition of a device is referenced by
  15115. the EEP (RORG-FUNC-TYPE). Basically four groups (RORG) will be differed, e. g.
  15116. RPS (switches), 1BS (contacts), 4BS, VLD (sensors and controller). Some manufacturers use
  15117. additional proprietary extensions. RORG MSC is not supported except for few exceptions.
  15118. Further technical information can be found at the
  15119. <a href="http://www.enocean-alliance.org/de/enocean_standard/">EnOcean Alliance</a>,
  15120. see in particular the
  15121. <a href="http://www.enocean-alliance.org/eep/">EnOcean Equipment Profiles (EEP)</a>
  15122. <br><br>
  15123. The supplementary Generic Profiles approach instead defines a language to communicate the
  15124. transmitted data types and ranges. The devices becomes self describing on their data
  15125. structures in communication. The Generic Profiles include a language definition with
  15126. a parameter selection that covers every possible measured value to be transmitted.
  15127. Therefore, the approach does not only define parameters for the value recalculation algorithm
  15128. but also includes specific signal definition. (e.g. physical units). Further technical
  15129. information can be found at the
  15130. <a href="https://www.enocean-alliance.org/fileadmin/redaktion/enocean_alliance/pdf/GenericProfiles_V1_Extract.pdf">Generic Profiles 1.0 Abstract</a>
  15131. <br><br>
  15132. Smart Acknowledge (Smart Ack) enables a special bidirectional communication. The communication is managed by a
  15133. Controller that responds to the devices telegrams with acknowledges. Smart Ack is a bidirectional communication
  15134. protocol between two actors. At least one actor must be an energy autarkic Sensor, and at least one must be a line
  15135. powered Controller (Fhem). A sensor sends its data and expects the answer telegram in a predefined very short
  15136. time slot. In this time Sensors receiver is active. For this purpose we declare a Post Master with Mail Boxes.
  15137. A Mail Box is like a letter box for a Sensor and it specific to a single sender. Telegrams from Fhem are collected
  15138. into the Mail Box. A Sensor can reclaim telegrams that are in his Mail Box.
  15139. <br><br>
  15140. Fhem recognizes a number of devices automatically. In order to teach-in, for
  15141. some devices the sending of confirmation telegrams has to be turned on.
  15142. Some equipment types and/or device models must be manually specified.
  15143. Do so using the <a href="#EnOceanattr">attributes</a>
  15144. <a href="#subType">subType</a> and <a href="#model">model</a>, see chapter
  15145. <a href="#EnOceanset">Set</a> and
  15146. <a href="#EnOceanevents">Generated events</a>. With the help of additional
  15147. <a href="#EnOceanattr">attributes</a>, the behavior of the devices can be
  15148. changed separately.
  15149. <br><br>
  15150. Fhem and the EnOcean devices must be trained with each other. To this, Fhem
  15151. must be in the learning mode, see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>,
  15152. <a href="#EnOcean_smartAck">Smart Ack Learning</a> and <a href="#TCM_learningMode">learningMode</a>.
  15153. The teach-in procedure depends on the type of the devices.
  15154. <br><br>
  15155. Switches (EEP RPS) and contacts (EEP 1BS) are recognized when receiving the first message.
  15156. Contacts can also send a teach-in telegram. Fhem not need this telegram.
  15157. Sensors (EEP 4BS) has to send a teach-in telegram. The profile-less
  15158. 4BS teach-in procedure transfers no EEP profile identifier and no manufacturer
  15159. ID. In this case Fhem does not recognize the device automatically. The proper
  15160. device type must be set manually, use the <a href="#EnOceanattr">attributes</a>
  15161. <a href="#subType">subType</a>, <a href="#manufID">manufID</a> and/or
  15162. <a href="#model">model</a>. If the EEP profile identifier and the manufacturer
  15163. ID are sent the device is clearly identifiable. Fhem automatically assigns
  15164. these devices to the correct profile.
  15165. <br><br>
  15166. 4BS devices can also be taught in special cases by using of confirmation telegrams. This method
  15167. is used for the EnOcean Tipp-Funk devices. The function is activated via the attribute [<a href="#EnOcean_teachMethod">teachMethod</a>] = confirm.<br>
  15168. For example the remote device Eltako TF100D can be learned as follows
  15169. <ul><br>
  15170. <code>define &lt;name&gt; EnOcean H5-38-08</code><br>
  15171. set TF100D in learning mode<br>
  15172. <code>set &lt;name&gt; teach</code>
  15173. </ul>
  15174. <br>
  15175. Some 4BS, VLD or MSC devices must be paired bidirectional,
  15176. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.
  15177. <br><br>
  15178. Devices that communicate encrypted, has to taught-in through specific procedures.
  15179. <br><br>
  15180. Smart Ack Learning is a futher process where devices exchange information about each
  15181. other in order to create the logical links in the EnOcean network and a Post Master Mail Box.
  15182. It can result in Learn In or Learn Out, see <a href="#EnOcean_smartAck">Smart Ack Learning</a>.
  15183. <br><br>
  15184. Fhem supports many of most common EnOcean profiles and manufacturer-specific
  15185. devices. Additional profiles and devices can be added if required.
  15186. <br><br>
  15187. In order to enable communication with EnOcean remote stations a
  15188. <a href="#TCM">TCM</a> module is necessary.
  15189. <br><br>
  15190. Please note that EnOcean repeaters also send Fhem data telegrams again.
  15191. Use the TCM <code>attr &lt;name&gt; <a href="#blockSenderID">blockSenderID</a> own</code>
  15192. to block receiving telegrams with a TCM SenderIDs.
  15193. <br><br>
  15194. <b>Observing Functions</b><br>
  15195. <ul>
  15196. Interference or overloading of the radio transmission can prevent the reception of Fhem
  15197. commands at the receiver. With the help of the observing function Fhem checks the reception
  15198. of the acknowledgment telegrams of the actuator. If within one second no acknowledgment
  15199. telegram is received, the last set command is sent again.
  15200. The set command is repeated a maximum of 5 times. The maximum number can be specified in the attribute
  15201. <a href="#EnOcean_observeCmdRepetition">observeCmdRepetition</a>.<br>
  15202. The function can only be used if the actuator immediately after the reception of
  15203. the set command sends an acknowledgment message.<br>
  15204. The observing function is turned on by the Attribute <a href="#EnOcean_observe">observe.</a>
  15205. In addition, further devices can be monitored. The names of this devices can be entered in the
  15206. <a href="#EnOcean_observeRefDev">observeRefDev</a> attribute. If additional device are specified,
  15207. the monitoring is stopped as soon as the first acknowledgment telegram of one of the devices was received (OR logic).
  15208. If the <a href="#EnOcean_observeLogic">observeLogic</a> attribute is set to "and", the monitoring is stopped when a telegram
  15209. was received by all devices (AND logic). Please note that the name of the own device has also to be entered in the
  15210. <a href="#EnOcean_observeRefDev">observeRefDev</a> if required.<br>
  15211. If the maximum number of retries is reached and still no all acknowledgment telegrams has been received, the reading
  15212. "observeFailedDev" shows the faulty devices and the command can be executed, that is stored in the
  15213. <a href="#EnOcean_observeErrorAction">observeErrorAction</a> attribute.
  15214. <br><br>
  15215. </ul>
  15216. <b>Energy Management</b><br>
  15217. <ul>
  15218. <li><a href="#demand_response">Demand Response</a> (EEP A5-37-01)</li>
  15219. Demand Response (DR) is a standard to allow utility companies to send requests for reduction in power
  15220. consumption during peak usage times. It is also used as a means to allow users to reduce overall power
  15221. comsumption as energy prices increase. The EEP was designed with a very flexible setting for the level
  15222. (0...15) as well as a default level whereby the transmitter can specify a specific level for all
  15223. controllers to use (0...100 % of either maximum or current power output, depending on the load type).
  15224. The profile also includes a timeout setting to indicate how long the DR event should last if the
  15225. DR transmitting device does not send heartbeats or subsequent new DR levels.<br>
  15226. The DR actor controls the target actuators such as switches, dimmers etc. The DR actor
  15227. is linked to the FHEM target actors via the attribute <a href="#EnOcean_demandRespRefDev">demandRespRefDev</a>.<br>
  15228. <ul>
  15229. <li>Standard actions are available for the following profiles:</li>
  15230. <ul>
  15231. <li>switch (setting the switching command for min, max by the attribute <a href="#EnOcean_demandRespMin">demandRespMin</a>,
  15232. <a href="#EnOcean_demandRespMax">demandRespMax</a>)</li>
  15233. <li>gateway/switching (on, off)</li>
  15234. <li>gateway/dimming (dim 0...100, relative to the max or current set value)</li>
  15235. <li>lightCtrl.01 (dim 0...255)</li>
  15236. <li>actuator.01 (dim 0...100)</li>
  15237. <li>roomSensorControl.01 (setpoint 0...255)</li>
  15238. <li>roomSensorControl.05 (setpoint 0...255 or nightReduction 0...5 for Eltako devices)</li>
  15239. <li>roomCtrlPanel.00 (roomCtrlMode comfort|economy)</li>
  15240. </ul>
  15241. <li>On the target actuator can be specified alternatively a freely definable command.
  15242. The command sequence is stored in the attribute <a href="#EnOcean_demandRespAction">demandRespAction</a>.
  15243. The command sequence can be designed similar to "notify". For the command sequence predefined variables can be used,
  15244. eg. $LEVEL. This actions can be executed very flexible depending on the given energy
  15245. reduction levels.
  15246. </li>
  15247. <li>Alternatively or additionally, a custom command sequence in the DR profile itself
  15248. can be stored.
  15249. </li>
  15250. </ul>
  15251. The profile has a master and slave mode.
  15252. <ul>
  15253. <li>In slave mode, demand response data telegrams received eg a control unit of the power utility,
  15254. evaluated and the corresponding commands triggered on the linked target actuators. The behavior in
  15255. slave mode can be changed by multiple attributes.
  15256. </li>
  15257. <li>In master mode, the demand response level is set by set commands and thus sends a corresponding
  15258. data telegram and the associated target actuators are controlled. The demand response control
  15259. value are specified by "level", "power", "setpoint" "max" or "min". Each other settings are
  15260. calculated proportionally. In normal operation, ie without power reduction, the control value (level)
  15261. is 15. Through the optional parameters "powerUsageScale", "randomStart", "randomEnd" and "timeout"
  15262. the control behavior can be customized. The threshold at which the reading "powerUsageLevel"
  15263. between "min" and "max" switch is specified with the attribute
  15264. <a href="#EnOcean_demandRespThreshold">demandRespThreshold</a>.
  15265. </li>
  15266. </ul>
  15267. Additional information about the profile itself can be found in the EnOcean EEP documentation.
  15268. <br><br>
  15269. </ul>
  15270. <b>Remote Management</b><br>
  15271. <ul>
  15272. Remote Management allows EnOcean devices to be configured and maintained over the air.
  15273. Thanks to Remote Management, sensors or switches IDs, for instance, can be stored or deleted from
  15274. already installed actuators or gateways which are hard to access. Remote Management also allows querying
  15275. debug information from the Remote Device and calling some manufacturer implemented functions.<br>
  15276. Remote Management is performed by the Remote Manager, operated by the actor, on the
  15277. managed Remote Device (Sensor, Gateway). The management is done through a series of
  15278. commands and responding answers. Actor sends the commands to the Remote Device. Remote
  15279. Device sends answers to the actor. The commands indicate the Remote Device what to do.
  15280. Remote Device answers if requested by the command. The commands belong to one of the
  15281. main use case categories, which are:
  15282. <ul>
  15283. <li>Security</li>
  15284. <li>Locate / indentify remote device</li>
  15285. <li>Get status</li>
  15286. <li>Extended function</li>
  15287. </ul>
  15288. The management is often done with a group of Remote Devices. Commands are sent as
  15289. addressed unicast telegrams, usually. In special cases broadcast transmission is also available.
  15290. To avoid telegram collisions the Remote Devices respond to broadcast commands with a
  15291. random delay.<br>
  15292. The Security, Locate, and Get Status options provide to the actor basic operability of Remote
  15293. management. Their purpose is to ensure the proper work of Remote Management when
  15294. operating with several Remote Devices. These functions behave in the same way on every
  15295. Remote Device. Every product that supports Remote Management provides these options.<br>
  15296. Extended functions provide the real benefit of Remote Management. They vary from Remote
  15297. Device to Remote Device. They depend on how and where the Remote Device is used.
  15298. Therefore, not every Remote Device provides every extended function. It depends on the
  15299. programmer / customer what extended functions he wants to add. There is a list of specified
  15300. commands, but the manufacturer can also add manufacturer specific extended functions. These
  15301. functions are identified by the manufacturer ID.<br>
  15302. More information can be found on the <a href="http://www.enocean.com">EnOcean websites</a>.<br><ber>
  15303. Fhem operates primarily as a remote manager. For tests but also a client device can be created.
  15304. <br><br>
  15305. The remote manager function must be activated for the desired device by
  15306. <ul><br>
  15307. <code>attr &lt;remote device name&gt; remote manager</code><br>
  15308. </ul>
  15309. <br><br>
  15310. The remote client device must be defined as follows<br>
  15311. <ul><br>
  15312. <code>define &lt;client name&gt; EnOcean C5-00-00</code><br>
  15313. </ul><br>
  15314. and has to by unlocked for t seconds
  15315. <ul><br>
  15316. <code>set &lt;client name&gt; unlock &lt;t/s&gt;</code><br>
  15317. </ul><br>
  15318. Only one remote management client device should be defined.<br><br>
  15319. For security reasons the remote management commands can only be accessed in the unlock
  15320. period. The period can be entered in two cases:
  15321. <ul>
  15322. <li>Within 30min after device power-up if no CODE is set</li>
  15323. <li>Within 30min after an unlock command with a correct 32bit security code is received</li>
  15324. </ul>
  15325. The unlock/lock period can be accessed only with the security code. The security code can be
  15326. set whenever the Remote Device accepts remote management commands.<br>
  15327. When the Remote Device is locked it does not respond to any command, but unlock and ping.
  15328. When a wrong security code is received the Remote Device does not process unlock commands
  15329. for a security period of 30 seconds.<br>
  15330. Security code=0x000000 is the default value and has to be interpreted as: no CODE has been
  15331. set. The actor can also set the security code to 0x000000 from a previously set value. If no
  15332. security code is set, unlock after the unlock period is not processed. Only ping will be
  15333. processed. Remote Management is not available until next power up. 0xFFFFFFFF is reserved
  15334. and can not be used as security code.<br><br>
  15335. To administrate a remote device whose Remote ID must be known. The Remote ID can be determined
  15336. as follows:
  15337. <ul><br>
  15338. <code>attr &lt;name&gt; remote manager</code><br>
  15339. power-up the remote device<br>
  15340. <code>get &lt;name&gt; remoteID</code><br><br>
  15341. </ul>
  15342. All commands are described in the remote management chapters of the <a href="#EnOcean_remoteSet">set</a>-
  15343. and <a href="#EnOcean_remoteGet">get</a>-commands.<br><br>
  15344. The Remote Management Function is configured using the following attributes:<br>
  15345. <ul>
  15346. <li><a href="#EnOcean_remoteCode">remoteCode</a></li>
  15347. <li><a href="#EnOcean_remoteEEP">remoteEEP</a></li>
  15348. <li><a href="#EnOcean_remoteID">remoteID</a></li>
  15349. <li><a href="#EnOcean_remoteManagement">remoteManagement</a></li>
  15350. <li><a href="#EnOcean_remoteManufID">remoteManufID</a></li>
  15351. </ul><br>
  15352. The content of events is described in the chapter <a href="#EnOcean_remoteEvents">Remote Management Events</a><br><br>.
  15353. The following extended functions are supported:
  15354. <ul>
  15355. <li>210:remoteLinkTableInfo</li>
  15356. <li>211:remoteLinkTable</li>
  15357. <li>212:remoteLinkTable</li>
  15358. <li>213:remoteLinkTableGP</li>
  15359. <li>214:remoteLinkTableGP</li>
  15360. <li>220:remoteLearnMode</li>
  15361. <li>221:remoteTeach</li>
  15362. <li>224:remoteReset</li>
  15363. <li>225:remoteRLT</li>
  15364. <li>226:remoteApplyChanges</li>
  15365. <li>227:remoteProductID</li>
  15366. <li>230:remoteDevCfg</li>
  15367. <li>231:remoteDevCfg</li>
  15368. <li>232:remoteLinkCfg</li>
  15369. <li>233:remoteLinkCfg</li>
  15370. <li>240:remoteAck</li>
  15371. <li>250:remoteRepeater</li>
  15372. <li>251:remoteRepeater</li>
  15373. <li>252:remoteRepeaterFilter</li>
  15374. </ul>
  15375. <br><br>
  15376. </ul>
  15377. <b>Radio Link Test</b><br>
  15378. <ul>
  15379. Units supporting the Radio Link Test (RLT) shall offer a functionality that allows for radio link testing between them
  15380. (Position A to Position B, point-to-point only). Fhem support at least 1BS and 4BS test messages. When two units
  15381. perform radio link testing one unit needs to act in a mode called RLT Master and the other unit needs to act in
  15382. a mode called RLT Slave. Fhem acts as RLT Master (subType radioLinkTest).<br>
  15383. The Radio Link Test device must be defined as follows<br>
  15384. <ul><br>
  15385. <code>define &lt;name&gt; EnOcean A5-3F-00</code><br>
  15386. </ul><br>
  15387. and has to by activated
  15388. <ul><br>
  15389. <code>set &lt;name&gt; standby</code><br>
  15390. </ul><br>
  15391. Alternatively, the device can also be created automatically by autocreate. Only one RLT device may be defined in FHEM.<br>
  15392. After activation the RLT Master listens for RLT Query messages. On reception of at least one RLT Query messsage the
  15393. RLT Master responds and starts transmission of RLT MasterTest messages. After that the RLT Master awaits the response
  15394. from the RLT Slave.<br>
  15395. A radio link test communication consits of a minimum of 16 and a maximum of 256 RLT MasterTest messages. When the
  15396. radio link test communication is completed the RLT Master gets deactivated automatically. The test results can be
  15397. found in the log file.
  15398. <br><br>
  15399. </ul>
  15400. <b>Security features</b><br>
  15401. <ul>
  15402. The receiving and sending of encrypted messages is supported. This module currently allows the secure operating mode of PTM 215
  15403. based switches.<br>
  15404. To receive secured telegrams, you first have to start the teach in mode via<br><br>
  15405. <code>set &lt;IODev&gt; teach &lt;t/s&gt;</code><br><br>
  15406. and then doing the following on the PTM 215 module:<br>
  15407. <ul>
  15408. <li>Remove the switch cover of the module</li>
  15409. <li>Press both buttons of one rocker side (A0 & A1 or B0 & B1)</li>
  15410. <li>While keeping the buttons pressed actuate the energy bow twice.</li><br>
  15411. </ul>
  15412. This generates two teach-in telegrams which create a Fhem device with the subType "switch.00" and synchronize the Fhem with
  15413. the PTM 215. Both the Fhem and the PTM 215 now maintain a counter which is used to generate a rolling code encryption scheme.
  15414. Also during teach-in, a private key is transmitted to the Fhem. The counter value is allowed to desynchronize for a maximum of
  15415. 128 counts, to allow compensating for missed telegrams, if this value is crossed you need to teach-in the PTM 215 again. Also
  15416. if your Fhem installation gets erased including the state information, you need to teach in the PTM 215 modules again (which
  15417. you would need to do anyway).<br><br>
  15418. To send secured telegrams, you first have send a secure teach-in to the remode device<br><br>
  15419. <ul>
  15420. <code>set &lt;name&gt; teachInSec</code><br><br>
  15421. </ul>
  15422. As for the security of this solution, if someone manages to capture the teach-in telegrams, he can extract the private key,
  15423. so the added security isn't perfect but relies on the fact, that none listens to you setting up your installation.
  15424. <br><br>
  15425. The cryptographic functions need the additional Perl modules Crypt/Rijndael and Crypt/Random. The module must be installed manually.
  15426. With the help of CPAN at the operating system level, for example,<br><br>
  15427. <ul>
  15428. <code>/usr/bin/perl -MCPAN -e 'install Crypt::Rijndael'</code><br>
  15429. <code>/usr/bin/perl -MCPAN -e 'install Crypt::Random'</code>
  15430. </ul>
  15431. <br><br>
  15432. </ul>
  15433. <a name="EnOceandefine"></a>
  15434. <b>Define</b>
  15435. <ul>
  15436. <code>define &lt;name&gt; EnOcean &lt;DEF&gt; [&lt;EEP&gt;]|getNextID|&lt;EEP&gt;</code>
  15437. <br><br>
  15438. Define an EnOcean device, connected via a <a href="#TCM">TCM</a> modul. The
  15439. &lt;DEF&gt; is the SenderID/DestinationID of the device (8 digit hex number), for example
  15440. <ul><br>
  15441. <code>define switch1 EnOcean FFC54500</code><br>
  15442. </ul><br>
  15443. In order to control devices, you cannot reuse the SenderIDs/
  15444. DestinationID of other devices (like remotes), instead you have to create
  15445. your own, which must be in the allowed SenderID range of the underlying Fhem
  15446. IO device, see <a href="#TCM">TCM</a> BaseID, LastID. For this first query the
  15447. <a href="#TCM">TCM</a> with the <code>get &lt;tcm&gt; baseID</code> command
  15448. for the BaseID. You can use up to 128 IDs starting with the BaseID shown there.
  15449. If you are using an Fhem SenderID outside of the allowed range, you will see an
  15450. ERR_ID_RANGE message in the Fhem log.<br>
  15451. FHEM can assign a free SenderID alternatively, for example
  15452. <ul><br>
  15453. <code>define switch1 EnOcean getNextID</code><br>
  15454. </ul><br>
  15455. If the EEP is known, the appropriate device can be created with the basic parameters, for example
  15456. <ul><br>
  15457. <code>define sensor1 EnOcean FFC54500 A5-02-05</code><br>
  15458. </ul><br>
  15459. or
  15460. <ul><br>
  15461. <code>define sensor1 EnOcean A5-02-05</code><br>
  15462. </ul><br>
  15463. Inofficial EEP for special devices
  15464. <ul>
  15465. <li>G5-07-01 PioTek-Tracker<br></li>
  15466. <li>G5-10-12 Room Sensor and Control Unit [Eltako FUTH65D]<br></li>
  15467. <li>G5-38-08 Gateway, Dimming [Eltako FSG, FUD]<br></li>
  15468. <li>H5-38-08 Gateway, Dimming [Eltako TF61D, TF100D]<br></li>
  15469. <li>M5-38-08 Gateway, Switching [Eltako FSR14]<br></li>
  15470. <li>N5-38-08 Gateway, Switching [Eltako TF61L, TF61R, TF100A, TF100L]<br></li>
  15471. <li>G5-3F-7F Shutter [Eltako FSB]<br></li>
  15472. <li>H5-3F-7F Shutter [Eltako TF61J]<br></li>
  15473. <li>L6-02-01 Smoke Detector [Eltako FRW]<br></li>
  15474. <li>G5-ZZ-ZZ Light and Presence Sensor [Omnio Ratio eagle-PM101]<br></li>
  15475. <li>ZZ-ZZ-ZZ EnOcean RAW profile<br></li>
  15476. <br><br>
  15477. </ul>
  15478. The <a href="#autocreate">autocreate</a> module may help you if the actor or sensor send
  15479. acknowledge messages or teach-in telegrams. In order to control this devices e. g. switches with
  15480. additional SenderIDs you can use the attributes <a href="#subDef">subDef</a>,
  15481. <a href="#subDef0">subDef0</a> and <a href="#subDefI">subDefI</a>.<br>
  15482. Fhem communicates unicast, if bidirectional 4BS or UTE teach-in is used, see
  15483. <a href="#EnOcean_teach-in"> Bidirectional Teach-In / Teach-Out</a>. In this case
  15484. Fhem send unicast telegrams with its SenderID and the DestinationID of the device.
  15485. <br><br>
  15486. </ul>
  15487. <a name="EnOceaninternals"></a>
  15488. <b>Internals</b>
  15489. <ul>
  15490. <li>DEF: 0000000 ... FFFFFFFF|&lt;EEP&gt;<br>
  15491. EnOcean DestinationID or SenderID<br>
  15492. If the attributes subDef* are set, this values are used as EnOcean SenderID.<br>
  15493. For an existing device, the device can be re-parameterized by entering the EEP.<br>
  15494. </li>
  15495. <li>&lt;IODev&gt;_DestinationID: 0000000 ... FFFFFFFF<br>
  15496. Received destination address, Broadcast radio: FFFFFFFF<br>
  15497. </li>
  15498. <li>&lt;IODev&gt;_RSSI: LP/dBm<br>
  15499. Received signal strength indication (best value of all received subtelegrams)<br>
  15500. </li>
  15501. <li>&lt;IODev&gt;_ReceivingQuality: excellent|good|bad<br>
  15502. excellent: RSSI >= -76 dBm (internal standard antenna sufficiently)<br>
  15503. good: RSSI < -76 dBm and RSSI >= -87 dBm (good antenna necessary)<br>
  15504. bad: RSSI < -87 dBm (repeater required)<br>
  15505. </li>
  15506. <li>&lt;IODev&gt;_RepeatingCounter: 0...2<br>
  15507. Number of forwardings by repeaters<br>
  15508. </li>
  15509. <br><br>
  15510. </ul>
  15511. <a name="EnOceanset"></a>
  15512. <b>Set</b>
  15513. <ul>
  15514. <li><a name="EnOcean_teach-in">Teach-In / Teach-Out</a>
  15515. <ul>
  15516. <li>Teach-in remote devices</li>
  15517. <br>
  15518. <code>set &lt;IODev&gt; teach &lt;t/s&gt;</code>
  15519. <br><br>
  15520. Set Fhem in the learning mode.<br>
  15521. A device, which is then also put in this state is to paired with
  15522. Fhem. Bidirectional Teach-In / Teach-Out is used for some 4BS, VLD and MSC devices,
  15523. e. g. EEP 4BS, RORG A5-20-01 (Battery Powered Actuator).<br>
  15524. Bidirectional Teach-In for 4BS, UTE and Generic Profiles are supported.<br>
  15525. <code>IODev</code> is the name of the TCM Module.<br>
  15526. <code>t/s</code> is the time for the learning period.
  15527. <br><br>
  15528. Types of learning modes see <a href="#TCM_learningMode">learningMode</a>
  15529. <br><br>
  15530. Example:
  15531. <ul><code>set TCM_0 teach 600</code></ul>
  15532. <br>
  15533. <li>RPS profiles Teach-In (switches)</li>
  15534. <br>
  15535. <code>set &lt;name&gt; A0|AI|B0|BI|C0|CI|D0|DI</code>
  15536. <br><br>
  15537. Send teach-in telegram to remote device.
  15538. <br><br>
  15539. <li>1BS profiles Teach-In (contact)</li>
  15540. <br>
  15541. <code>set &lt;name&gt; teach</code>
  15542. <br><br>
  15543. Send teach-in telegram to remote device.
  15544. <br><br>
  15545. <li>4BS profiles Teach-In (sensors, dimmer, room controller etc.)</li>
  15546. <br>
  15547. <code>set &lt;name&gt; teach</code>
  15548. <br><br>
  15549. Send teach-in telegram to remote device.<br>
  15550. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15551. is assigned automatically.
  15552. <br><br>
  15553. <li>UTE - Universal Uni- and Bidirectional Teach-In</li>
  15554. <br>
  15555. <code>set &lt;name&gt; teachIn|teachOut</code>
  15556. <br><br>
  15557. Send teach-in telegram to remote device.<br>
  15558. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15559. is assigned automatically.
  15560. <br><br>
  15561. <li>Generic Profiles Teach-In</li>
  15562. <br>
  15563. <code>set &lt;name&gt; teachIn|teachOut</code>
  15564. <br><br>
  15565. Send teach-in telegram to remote device.<br>
  15566. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15567. is assigned automatically.
  15568. <br><br>
  15569. <li>Secure Devices Teach-In</li>
  15570. <br>
  15571. <code>set &lt;name&gt; teachInSec</code>
  15572. <br><br>
  15573. Secure teach-in to the remode device.<br>
  15574. If no SenderID (attr subDef) was assigned before a learning telegram is sent for the first time, a free SenderID
  15575. is assigned automatically.
  15576. <br><br>
  15577. </ul>
  15578. </li>
  15579. <li><a name="EnOcean_smartAck">Smart Ack Learning</a>
  15580. <ul>
  15581. <li>Teach-in remote Smart Ack devices</li>
  15582. <br>
  15583. <code>set &lt;IODev&gt; smartAckLearn &lt;t/s&gt;</code>
  15584. <br><br>
  15585. Set Fhem in the Smart Ack learning mode.<br>
  15586. The post master fuctionality must be activated using the command <code>smartAckMailboxMax</code> in advance.<br>
  15587. The simple learnmode is supported, see <a href="#TCM_smartAckLearnMode">smartAckLearnMode</a><br>
  15588. A device, which is then also put in this state is to paired with
  15589. Fhem. Bidirectional learn in for 4BS, UTE and Generic Profiles are supported.<br>
  15590. <code>IODev</code> is the name of the TCM Module.<br>
  15591. <code>t/s</code> is the time for the learning period.
  15592. <br><br>
  15593. Example:
  15594. <ul><code>set TCM_0 smartAckLearn 600</code></ul>
  15595. <br>
  15596. </ul>
  15597. </li>
  15598. <li><a name="EnOcean_remoteSet">Remote Management</a>
  15599. <ul>
  15600. <code>set &lt;name&gt; &lt;value&gt;</code>
  15601. <br><br>
  15602. where <code>value</code> is
  15603. <li>remoteAction<br>
  15604. sent action command to perfoms an action, depending on the functionality of the device</li>
  15605. <li>remoteApplyChanges devCfg|linkTable|no_change<br>
  15606. apply changes</li>
  15607. <li>remoteDevCfg &lt;index&gt; &lt;value&gt;<br>
  15608. set configuration</li>
  15609. <li>remoteLinkTable in|out &lt;index&gt; &lt;ID&gt; &lt;EEP&gt; &lt;channel&gt;<br>
  15610. set link table content</li>
  15611. <li>remoteLinkCfg in|out &lt;index&gt; &lt;data index&gt; &lt;value&gt;<br>
  15612. set link based configuration</li>
  15613. <li>remoteLinkTableGP in|out &lt;index&gt; &lt;GP channel description&gt;<br>
  15614. set link table content</li>
  15615. <li>remoteLock<br>
  15616. locks the remote device or local client</li>
  15617. <li>remoteLearnMode in|out|off &lt;index&gt;<br>
  15618. initiate remote learn-in or learn-out of inbound index</li>
  15619. <li>remoteReset devCfg|linkTableIn|linkTableOut|no_change<br>
  15620. reset to defaults</li>
  15621. <li>remoteRLT on|off &lt;number of RLT slaves&gt;<br>
  15622. reset to defaults</li>
  15623. <li>remoteRepeater on|off|filter &lt;level&gt; &lt;filter structure&gt;<br>
  15624. set repeater functions</li>
  15625. <li>remoteRepeaterFilter apply|block|delete|deleteAll destinationID|sourceID|rorg|rssi &lt;filter value&gt;<br>
  15626. set repeater functions</li>
  15627. <li>remoteSetCode<br>
  15628. set the remote security code</li>
  15629. <li>remoteTeach &lt;channel&gt;<br>
  15630. request teach-in telegram from channel 00..FF</li>
  15631. <li>remoteUnlock [1...1800]<br>
  15632. unlocks the remote device or local client<br>
  15633. The unlock period can be set in the client mode between 1s and 1800 s.</li>
  15634. <br>
  15635. [&lt;channel&gt;] = 00...FF<br>
  15636. [&lt;EEP&gt;] = &lt;RORG&gt;-&lt;function&gt;-&lt;type&gt;<br>
  15637. [&lt;filter structure&gt;] = AND|OR<br>
  15638. [&lt;filter value&gt;] = &lt;destinationID&gt;|&lt;sourceID&gt;|&lt;RORG&gt;|&lt;LP/dBm&gt;<br>
  15639. [&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>
  15640. [&lt;ID&gt;] = 00000001...FFFFFFFE<br>
  15641. [&lt;index&gt;] = 00...FF<br>
  15642. [&lt;number of RLT slaves&gt;] = 01..7F<br>
  15643. [&lt;level&gt;] = 1|2<br>
  15644. [&lt;data index&gt;] = 0000...FFFF<br>
  15645. [&lt;value&gt;] = n x 00...FF<br>
  15646. </ul><br>
  15647. </li><br>
  15648. <li>Switch, Pushbutton Switch (EEP F6-02-01 ... F6-03-02)<br>
  15649. RORG RPS [default subType]
  15650. <ul>
  15651. <code>set &lt;name&gt; &lt;value&gt;</code>
  15652. <br><br>
  15653. where <code>value</code> is one of A0, AI, B0, BI, C0, CI, D0, DI,
  15654. combinations of these and released. First and second action can be sent
  15655. simultaneously. Separate first and second action with a comma.<br>
  15656. In fact we are trying to emulate a PT200 type remote.<br>
  15657. If you define an <a href="#eventMap">eventMap</a> attribute with on/off,
  15658. then you will be able to easily set the device from the <a
  15659. href="#FHEMWEB">WEB</a> frontend.<br>
  15660. <a href="#setExtensions">set extensions</a> are supported, if the corresponding
  15661. <a href="#eventMap">eventMap</a> specifies the <code>on</code> and <code>off</code>
  15662. mappings, for example <code>attr <name> eventMap on-till:on-till AI:on A0:off</code>.<br>
  15663. With the help of additional <a href="#EnOceanattr">attributes</a>, the
  15664. behavior of the devices can be adapt.<br>
  15665. The attr subType must be switch. This is done if the device was created by autocreate.
  15666. <br><br>
  15667. Example:
  15668. <ul><code>
  15669. set switch1 BI<br>
  15670. set switch1 B0,CI<br>
  15671. attr eventMap BI:on B0:off<br>
  15672. set switch1 on<br>
  15673. </code></ul><br>
  15674. </ul>
  15675. </li>
  15676. <li>Staircase off-delay timer (EEP F6-02-01 ... F6-02-02)<br>
  15677. RORG RPS [Eltako FTN14, tested with Eltako FTN14 only]<br>
  15678. <ul>
  15679. <code>set &lt;name&gt; &lt;value&gt;</code>
  15680. <br><br>
  15681. where <code>value</code> is
  15682. <li>on<br>
  15683. issue switch on command</li>
  15684. <li>released<br>
  15685. start timer</li>
  15686. </ul><br>
  15687. Set attr eventMap to B0:on BI:off, attr subType to switch, attr
  15688. webCmd to on:released and if needed attr switchMode to pushbutton manually.<br>
  15689. The attr subType must be switch. This is done if the device was created by autocreate.<br>
  15690. Use the sensor type "Schalter" for Eltako devices. The Staircase
  15691. off-delay timer is switched on when pressing "on" and the time will be started
  15692. when pressing "released". "released" immediately after "on" is sent if
  15693. the attr switchMode is set to "pushbutton".
  15694. </li>
  15695. <br><br>
  15696. <li>Pushbutton Switch (EEP D2-03-00)<br>
  15697. RORG VLD [EnOcean PTM 215 Modul]
  15698. <ul>
  15699. <code>set &lt;name&gt; &lt;value&gt;</code>
  15700. <br><br>
  15701. where <code>value</code> is
  15702. <li>teachIn<br>
  15703. initiate UTE teach-in</li>
  15704. <li>teachInSec<br>
  15705. initiate secure teach-in</li>
  15706. <li>teachOut<br>
  15707. initiate UTE teach-out</li>
  15708. <li>A0|AI|B0|BI<br>
  15709. issue switch command</li>
  15710. <li>A0,B0|A0,AI|AI,B0|AI,BI<br>
  15711. issue switch command</li>
  15712. <li>pressed<br>
  15713. energy bow pressed</li>
  15714. <li>pressed34<br>
  15715. 3 or 4 buttons and energy bow pressed</li>
  15716. <li>released<br>
  15717. energy bow released</li><br>
  15718. </ul>
  15719. First and second action can be sent simultaneously. Separate first and second action with a comma.<br>
  15720. If you define an <a href="#eventMap">eventMap</a> attribute with on/off,
  15721. then you will be able to easily set the device from the <a href="#FHEMWEB">WEB</a> frontend.<br>
  15722. <a href="#setExtensions">set extensions</a> are supported, if the corresponding
  15723. <a href="#eventMap">eventMap</a> specifies the <code>on</code> and <code>off</code>
  15724. mappings, for example <code>attr <name> eventMap on-till:on-till AI:on A0:off</code>.<br>
  15725. If <a href="#EnOcean_comMode">comMode</a> is set to biDir the device can be controlled bidirectionally.<br>
  15726. With the help of additional <a href="#EnOceanattr">attributes</a>, the behavior of the devices can be adapt.<br>
  15727. The attr subType must be switch.00. This is done if the device was created by autocreate.
  15728. <br><br>
  15729. <ul>
  15730. Example:
  15731. <ul><code>
  15732. set switch1 BI<br>
  15733. set switch1 B0,CI<br>
  15734. attr eventMap BI:on B0:off<br>
  15735. set switch1 on<br>
  15736. </code></ul><br>
  15737. </ul>
  15738. </li>
  15739. <li>Single Input Contact, Door/Window Contact (EEP D5-00-01)<br>
  15740. RORG 1BS [tested with Eltako FSR14]
  15741. <ul>
  15742. <code>set &lt;name&gt; &lt;value&gt;</code>
  15743. <br><br>
  15744. where <code>value</code> is
  15745. <li>closed<br>
  15746. issue closed command</li>
  15747. <li>open<br>
  15748. issue open command</li>
  15749. <li>teach<br>
  15750. initiate teach-in</li>
  15751. </ul><br>
  15752. The attr subType must be contact. The attribute must be set manually.
  15753. </li><br><br>
  15754. <li>Room Sensor and Control Unit (EEP A5-10-02)<br>
  15755. [Thermokon SR04 PTS]<br>
  15756. <ul>
  15757. <code>set &lt;name&gt; &lt;value&gt;</code>
  15758. <br><br>
  15759. where <code>value</code> is
  15760. <li>teach<br>
  15761. initiate teach-in</li>
  15762. <li>setpoint [0 ... 255]<br>
  15763. Set the actuator to the specifed setpoint.</li>
  15764. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15765. Set the actuator to the scaled setpoint.</li>
  15766. <li>fanStage [auto|0|1|2|3]<br>
  15767. Set fan stage</li>
  15768. <li>switch [on|off]<br>
  15769. Set switch</li>
  15770. </ul><br>
  15771. The actual temperature will be taken from the temperature reported by
  15772. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15773. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15774. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15775. command is sent when the reference device is updated.<br>
  15776. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  15777. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  15778. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled setting
  15779. setpointScaled.<br>
  15780. The attr subType must be roomSensorControl.05. The attribute must be set manually.
  15781. </li>
  15782. <br><br>
  15783. <li>Room Sensor and Control Unit (EEP A5-10-03)<br>
  15784. [used for IntesisBox PA-AC-ENO-1i]<br>
  15785. <ul>
  15786. <code>set &lt;name&gt; &lt;value&gt;</code>
  15787. <br><br>
  15788. where <code>value</code> is
  15789. <li>teach<br>
  15790. initiate teach-in</li>
  15791. <li>setpoint [0 ... 255]<br>
  15792. Set the actuator to the specifed setpoint.</li>
  15793. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15794. Set the actuator to the scaled setpoint.</li>
  15795. <li>fanStage [auto|0|1|2|3]<br>
  15796. Set fan stage</li>
  15797. <li>switch [on|off]<br>
  15798. Set switch</li>
  15799. </ul><br>
  15800. The actual temperature will be taken from the temperature reported by
  15801. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15802. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15803. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15804. command is sent when the reference device is updated.<br>
  15805. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  15806. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  15807. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled setting
  15808. setpointScaled.<br>
  15809. The attr subType must be roomSensorControl.05 and attr manufID must be 019. The attribute must be set manually.
  15810. </li>
  15811. <br><br>
  15812. <li>Room Sensor and Control Unit (A5-10-06 plus night reduction)<br>
  15813. [Eltako FTR65DS, FTR65HS]<br>
  15814. <ul>
  15815. <code>set &lt;name&gt; &lt;value&gt;</code>
  15816. <br><br>
  15817. where <code>value</code> is
  15818. <li>teach<br>
  15819. initiate teach-in</li>
  15820. <li>desired-temp [t/&#176C [lock|unlock]]<br>
  15821. Set the desired temperature.</li>
  15822. <li>nightReduction [t/K [lock|unlock]]<br>
  15823. Set night reduction</li>
  15824. <li>setpointTemp [t/&#176C [lock|unlock]]<br>
  15825. Set the desired temperature</li>
  15826. </ul><br>
  15827. The actual temperature will be taken from the temperature reported by
  15828. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15829. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15830. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpointTemp
  15831. command is sent when the reference device is updated.<br>
  15832. This profil can be used with a further Room Sensor and Control Unit Eltako FTR55*
  15833. to control a heating/cooling relay FHK12, FHK14 or FHK61. If Fhem and FTR55*
  15834. is teached in, the temperature control of the FTR55* can be either blocked
  15835. or to a setpoint deviation of +/- 3 K be limited. For this use the optional parameter
  15836. [block] = lock|unlock, unlock is default.<br>
  15837. The attr subType must be roomSensorControl.05 and attr manufID must be 00D.
  15838. The attributes must be set manually.
  15839. </li>
  15840. <br><br>
  15841. <li>Room Sensor and Control Unit (EEP A5-10-10)<br>
  15842. [Thermokon SR04 * rH, Thanos SR *]<br>
  15843. <ul>
  15844. <code>set &lt;name&gt; &lt;value&gt;</code>
  15845. <br><br>
  15846. where <code>value</code> is
  15847. <li>teach<br>
  15848. initiate teach-in</li>
  15849. <li>setpoint [0 ... 255]<br>
  15850. Set the actuator to the specifed setpoint.</li>
  15851. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15852. Set the actuator to the scaled setpoint.</li>
  15853. <li>switch [on|off]<br>
  15854. Set switch</li>
  15855. </ul><br>
  15856. The actual temperature will be taken from the temperature reported by
  15857. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15858. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15859. The actual humidity will be taken from the humidity reported by
  15860. a humidity reference device <a href="#EnOcean_humidityRefDev">humidityRefDev</a>
  15861. primarily or from the attribute <a href="#EnOcean_humidity">humidity</a> if it is set.<br>
  15862. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15863. command is sent when the reference device is updated.<br>
  15864. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  15865. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  15866. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled setting
  15867. setpointScaled.<br>
  15868. The attr subType must be roomSensorControl.01. The attribute must be set manually.
  15869. </li>
  15870. <br><br>
  15871. <li>Room Sensor and Control Unit (EEP A5-10-12)<br>
  15872. [Eltako FUTH65D]<br>
  15873. <ul>
  15874. <code>set &lt;name&gt; &lt;value&gt;</code>
  15875. <br><br>
  15876. where <code>value</code> is
  15877. <li>teach<br>
  15878. initiate teach-in</li>
  15879. <li>setpoint [0 ... 255]<br>
  15880. Set the actuator to the specifed setpoint.</li>
  15881. <li>setpointScaled [&lt;floating-point number&gt;]<br>
  15882. Set the actuator to the scaled setpoint.</li>
  15883. <li>switch [on|off]<br>
  15884. Set switch</li>
  15885. </ul><br>
  15886. The actual temperature will be taken from the temperature reported by
  15887. a temperature reference device <a href="#temperatureRefDev">temperatureRefDev</a>
  15888. primarily or from the attribute <a href="#actualTemp">actualTemp</a> if it is set.<br>
  15889. If the attribute <a href="#EnOcean_setCmdTrigger">setCmdTrigger</a> is set to "refDev", a setpoint
  15890. command is sent when the reference device is updated.<br>
  15891. The attr subType must be roomSensorControl.01 and attr manufID must be 00D. The attribute must be set manually.
  15892. </li>
  15893. <br><br>
  15894. <li>Battery Powered Actuator (EEP A5-20-01)<br>
  15895. [Kieback&Peter MD15-FTL-xx]<br>
  15896. <ul>
  15897. <code>set &lt;name&gt; &lt;value&gt;</code>
  15898. <br><br>
  15899. where <code>value</code> is
  15900. <li>setpoint setpoint/%<br>
  15901. Set the actuator to the specifed setpoint (0...100). The setpoint can also be set by the
  15902. <a href="#EnOcean_setpointRefDev">setpointRefDev</a> device if it is set.</li>
  15903. <li>setpointTemp t/&#176C<br>
  15904. Set the actuator to the specifed temperature setpoint. The temperature setpoint can also be set by the
  15905. <a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a> device if it is set.<br>
  15906. The FHEM PID controller calculates the actuator setpoint based on the temperature setpoint. The controller's
  15907. operation can be set via the PID parameters <a href="#EnOcean_pidFactor_P">pidFactor_P</a>,
  15908. <a href="#EnOcean_pidFactor_I">pidFactor_I</a> and <a href="#EnOcean_pidFactor_D">pidFactor_D</a>.<br>
  15909. If the attribute pidCtrl is set to off, the PI controller of the actuator is used (selfCtrl mode). Please
  15910. read the instruction manual of the device, whether the device has an internal PI controller.<br></li>
  15911. <li>runInit<br>
  15912. Maintenance Mode: Run init sequence</li>
  15913. <li>valveOpens<br>
  15914. Maintenance Mode: Valve opens<br>
  15915. After the valveOpens command, the valve remains open permanently and can no longer be controlled by Fhem.
  15916. By pressing the button on the device itself, the actuator is returned to its normal operating state.</li>
  15917. <li>valveCloses<br>
  15918. Maintenance Mode: Valve closes</li>
  15919. </ul><br>
  15920. The Heating Radiator Actuating Drive is configured using the following attributes:<br>
  15921. <ul>
  15922. <li><a href="#EnOcean_pidActorCallBeforeSetting">pidActorCallBeforeSetting</a></li>
  15923. <li><a href="#EnOcean_pidActorErrorAction">pidActorErrorAction</a></li>
  15924. <li><a href="#EnOcean_pidActorErrorPos">pidActorErrorPos</a></li>
  15925. <li><a href="#EnOcean_pidActorLimitLower">pidActorLimitLower</a></li>
  15926. <li><a href="#EnOcean_pidActorLimitUpper">pidActorLimitUpper</a></li>
  15927. <li><a href="#EnOcean_pidCtrl">pidCtrl</a></li>
  15928. <li><a href="#EnOcean_pidDeltaTreshold">pidDeltaTreshold</a></li>
  15929. <li><a href="#EnOcean_pidFactor_P">pidFactor_P</a></li>
  15930. <li><a href="#EnOcean_pidFactor_I">pidFactor_I</a></li>
  15931. <li><a href="#EnOcean_pidFactor_D">pidFactor_D</a></li>
  15932. <li><a href="#EnOcean_pidIPortionCallBeforeSetting">pidIPortionCallBeforeSetting</a></li>
  15933. <li><a href="#EnOcean_pidSensorTimeout">pidSensorTimeout</a></li>
  15934. <li><a href="#EnOcean_rcvRespAction">rcvRespAction</a></li>
  15935. <li><a href="#EnOcean_setpointRefDev">setpointRefDev</a></li>
  15936. <li><a href="#EnOcean_setpointSummerMode">setpointSummerMode</a></li>
  15937. <li><a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a></li>
  15938. <li><a href="#temperatureRefDev">temperatureRefDev</a></li>
  15939. <li><a href="#EnOcean_summerMode">summerMode</a></li>
  15940. </ul>
  15941. The actual temperature will be reported by the Heating Radiator Actuating Drive or by the
  15942. <a href="#temperatureRefDev">temperatureRefDev</a> if it is set. The internal temperature sensor
  15943. of the Micropelt iTRV is not suitable as an actual temperature value for the PID controller.
  15944. An external room thermostat is required.<br>
  15945. The attr event-on-change-reading .* shut not by set. The PID controller expects periodic events.
  15946. If these are missing, a communication alarm is signaled.<br>
  15947. The attr subType must be hvac.01. This is done if the device was
  15948. created by autocreate. To control the device, it must be bidirectional paired,
  15949. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.<br>
  15950. The command is not sent until the device wakes up and sends a message, usually
  15951. every 10 minutes.
  15952. </li>
  15953. <br><br>
  15954. <li>Heating Radiator Actuating Drive (EEP A5-20-04)<br>
  15955. [Holter SmartDrive MX]<br>
  15956. <ul>
  15957. <code>set &lt;name&gt; &lt;value&gt;</code>
  15958. <br><br>
  15959. where <code>value</code> is
  15960. <li>setpoint setpoint/%<br>
  15961. Set the actuator to the specifed setpoint (0...100). The setpoint can also be set by the
  15962. <a href="#EnOcean_setpointRefDev">setpointRefDev</a> device if it is set.</li>
  15963. <li>setpointTemp t/&#176C<br>
  15964. Set the actuator to the specifed temperature setpoint. The temperature setpoint can also be set by the
  15965. <a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a> device if it is set.<br>
  15966. The FHEM PID controller calculates the actuator setpoint based on the temperature setpoint. The controller's
  15967. operation can be set via the PID parameters <a href="#EnOcean_pidFactor_P">pidFactor_P</a>,
  15968. <a href="#EnOcean_pidFactor_I">pidFactor_I</a> and <a href="#EnOcean_pidFactor_D">pidFactor_D</a>.</li>
  15969. <li>runInit<br>
  15970. Maintenance Mode: Run init sequence</li>
  15971. <li>valveOpens<br>
  15972. Maintenance Mode: Valve opens<br>
  15973. After the valveOpens command, the valve remains open permanently and can no longer be controlled by Fhem.
  15974. By pressing the button on the device itself, the actuator is returned to its normal operating state.</li>
  15975. <li>valveCloses<br>
  15976. Maintenance Mode: Valve closes</li>
  15977. </ul><br>
  15978. The Heating Radiator Actuating Drive is configured using the following attributes:<br>
  15979. <ul>
  15980. <li><a href="#EnOcean_blockKey">blockKey</a></li>
  15981. <li><a href="#EnOcean_displayOrientation">displayOrientation</a></li>
  15982. <li><a href="#EnOcean_measurementCtrl">measurementCtrl</a></li>
  15983. <li><a href="#model">model</a></li>
  15984. <li><a href="#EnOcean_pidActorCallBeforeSetting">pidActorCallBeforeSetting</a></li>
  15985. <li><a href="#EnOcean_pidActorErrorAction">pidActorErrorAction</a></li>
  15986. <li><a href="#EnOcean_pidActorErrorPos">pidActorErrorPos</a></li>
  15987. <li><a href="#EnOcean_pidActorLimitLower">pidActorLimitLower</a></li>
  15988. <li><a href="#EnOcean_pidActorLimitUpper">pidActorLimitUpper</a></li>
  15989. <li><a href="#EnOcean_pidCtrl">pidCtrl</a></li>
  15990. <li><a href="#EnOcean_pidDeltaTreshold">pidDeltaTreshold</a></li>
  15991. <li><a href="#EnOcean_pidFactor_P">pidFactor_P</a></li>
  15992. <li><a href="#EnOcean_pidFactor_I">pidFactor_I</a></li>
  15993. <li><a href="#EnOcean_pidFactor_D">pidFactor_D</a></li>
  15994. <li><a href="#EnOcean_pidIPortionCallBeforeSetting">pidIPortionCallBeforeSetting</a></li>
  15995. <li><a href="#EnOcean_pidSensorTimeout">pidSensorTimeout</a></li>
  15996. <li><a href="#EnOcean_setpointRefDev">setpointRefDev</a></li>
  15997. <li><a href="#EnOcean_setpointTempRefDev">setpointTempRefDev</a></li>
  15998. <li><a href="#temperatureRefDev">temperatureRefDev</a></li>
  15999. <li><a href="#EnOcean_summerMode">summerMode</a></li>
  16000. <li><a href="#EnOcean_wakeUpCycle">wakeUpCycle</a></li>
  16001. </ul>
  16002. The actual temperature will be reported by the Heating Radiator Actuating Drive or by the
  16003. <a href="#temperatureRefDev">temperatureRefDev</a> if it is set.<br>
  16004. The attr event-on-change-reading .* shut not by set. The PID controller expects periodic events.
  16005. If these are missing, a communication alarm is signaled.<br>
  16006. The attr subType must be hvac.04. This is done if the device was
  16007. created by autocreate. To control the device, it must be bidirectional paired,
  16008. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.<br>
  16009. The OEM version of the Holter SmartDrive MX has an internal PID controller. This function is activated by
  16010. attr <device> model OEM and attr <device> pidCtrl off.<br>
  16011. The command is not sent until the device wakes up and sends a message, usually
  16012. every 5 minutes.
  16013. </li>
  16014. <br><br>
  16015. <li>Generic HVAC Interface (EEP A5-20-10)<br>
  16016. [IntesisBox PA-AC-ENO-1i]<br>
  16017. <ul>
  16018. <code>set &lt;name&gt; &lt;value&gt;</code>
  16019. <br><br>
  16020. where <code>value</code> is
  16021. <li>ctrl auto|0...100<br>
  16022. Set control variable</li>
  16023. <li>fanSpeed auto|1...14<br>
  16024. Set fan speed</li>
  16025. <li>occupancy occupied|off|standby|unoccupied<br>
  16026. Set room occupancy</li>
  16027. <li>on<br>
  16028. Set on</li>
  16029. <li>off<br>
  16030. Set off</li>
  16031. <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>
  16032. Set mode</li>
  16033. <li>teach<br>
  16034. Teach-in</li>
  16035. <li>vanePosition auto|horizontal|position_2|position_3|position_4|vertical|swing|vertical_swing|horizontal_swing|hor_vert_swing|stop_swing<br>
  16036. Set vane position</li>
  16037. </ul><br>
  16038. The attr subType must be hvac.10. This is done if the device was
  16039. created by autocreate. To control the device, it must be bidirectional paired,
  16040. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.
  16041. </li>
  16042. <br><br>
  16043. <li>Generic HVAC Interface - Error Control (EEP A5-20-11)<br>
  16044. [IntesisBox PA-AC-ENO-1i]<br>
  16045. <ul>
  16046. <code>set &lt;name&gt; &lt;value&gt;</code>
  16047. <br><br>
  16048. where <code>value</code> is
  16049. <li>externalDisable disable|enable<br>
  16050. Set external disablement</li>
  16051. <li>remoteCtrl disable|enable<br>
  16052. Dieable/enable remote controller</li>
  16053. <li>teach<br>
  16054. Teach-in</li>
  16055. <li>window closed|opened<br>
  16056. Set window state</li>
  16057. </ul><br>
  16058. The attr subType must be hvac.11. This is done if the device was
  16059. created by autocreate. To control the device, it must be bidirectional paired,
  16060. see <a href="#EnOcean_teach-in">Teach-In / Teach-Out</a>.
  16061. </li>
  16062. <br><br>
  16063. <li>Energy management, <a name="demand_response">demand response</a> (EEP A5-37-01)<br>
  16064. demand response master commands<br>
  16065. <ul>
  16066. <code>set &lt;name&gt; &lt;value&gt;</code>
  16067. <br><br>
  16068. where <code>value</code> is
  16069. <li>level 0...15 [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16070. set demand response level</li>
  16071. <li>max [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16072. set power usage level to max</li>
  16073. <li>min [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16074. set power usage level to min</li>
  16075. <li>power power/% [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16076. set power</li>
  16077. <li>setpoint 0...255 [&lt;powerUsageScale&gt; [&lt;randomStart&gt; [&lt;randomEnd&gt; [timeout]]]]<br>
  16078. set setpoint</li>
  16079. <li>teach<br>
  16080. initiate teach-in</li>
  16081. </ul><br>
  16082. [&lt;powerUsageScale&gt;] = max|rel, [&lt;powerUsageScale&gt;] = max is default<br>
  16083. [&lt;randomStart&gt;] = yes|no, [&lt;randomStart&gt;] = no is default<br>
  16084. [&lt;randomEnd&gt;] = yes|no, [&lt;randomEnd&gt;] = no is default<br>
  16085. [timeout] = 0/min | 15/min ... 3825/min, [timeout] = 0 is default<br>
  16086. The attr subType must be energyManagement.01.<br>
  16087. This is done if the device was created by autocreate.<br>
  16088. </li>
  16089. <br><br>
  16090. <li><a name="Gateway">Gateway</a> (EEP A5-38-08)<br>
  16091. The Gateway profile include 7 different commands (Switching, Dimming,
  16092. Setpoint Shift, Basic Setpoint, Control variable, Fan stage, Blind Central Command).
  16093. The commands can be selected by the attribute gwCmd or command line. The attribute
  16094. entry has priority.<br>
  16095. <ul>
  16096. <code>set &lt;name&gt; &lt;value&gt;</code>
  16097. <br><br>
  16098. where <code>value</code> is
  16099. <li>&lt;gwCmd&gt; &lt;cmd&gt; [subCmd]<br>
  16100. initiate Gateway commands by command line</li>
  16101. <li>&lt;cmd&gt; [subCmd]<br>
  16102. initiate Gateway commands if attribute gwCmd is set.</li>
  16103. </ul><br>
  16104. The attr subType must be gateway. Attribute gwCmd can also be set to
  16105. switching|dimming|setpointShift|setpointBasic|controlVar|fanStage|blindCmd.<br>
  16106. This is done if the device was created by autocreate.<br>
  16107. For Eltako devices attributes must be set manually.
  16108. </li>
  16109. <br><br>
  16110. <li>Gateway (EEP A5-38-08)<br>
  16111. Switching<br>
  16112. [Eltako FLC61, FSA12, FSR14]<br>
  16113. <ul>
  16114. <code>set &lt;name&gt; &lt;value&gt;</code>
  16115. <br><br>
  16116. where <code>value</code> is
  16117. <li>teach<br>
  16118. initiate teach-in mode</li>
  16119. <li>on [lock|unlock]<br>
  16120. issue switch on command</li>
  16121. <li>off [lock|unlock]<br>
  16122. issue switch off command</li>
  16123. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16124. </ul><br>
  16125. The attr subType must be gateway and gwCmd must be switching. This is done if the device was
  16126. created by autocreate.<br>
  16127. For Eltako devices attributes must be set manually. For Eltako FSA12 attribute model must be set
  16128. to FSA12.
  16129. </li>
  16130. <br><br>
  16131. <li>Gateway (EEP A5-38-08)<br>
  16132. Dimming<br>
  16133. [Eltako FUD12, FUD14, FUD61, FUD70, FSG14, ...]<br>
  16134. <ul>
  16135. <code>set &lt;name&gt; &lt;value&gt;</code>
  16136. <br><br>
  16137. where <code>value</code> is
  16138. <li>dim/% [rampTime/s [lock|unlock]]<br>
  16139. issue dim command</li>
  16140. <li>teach<br>
  16141. initiate teach-in mode</li>
  16142. <li>on [lock|unlock]<br>
  16143. issue switch on command</li>
  16144. <li>off [lock|unlock]<br>
  16145. issue switch off command</li>
  16146. <li>dim dim/% [rampTime/s [lock|unlock]]<br>
  16147. issue dim command</li>
  16148. <li>dimup dim/% [rampTime/s [lock|unlock]]<br>
  16149. issue dim command</li>
  16150. <li>dimdown dim/% [rampTime/s [lock|unlock]]<br>
  16151. issue dim command</li>
  16152. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16153. </ul><br>
  16154. rampTime Range: t = 1 s ... 255 s or 0 if no time specified,
  16155. for Eltako: t = 1 = fast dimming ... 255 = slow dimming or 0 = dimming speed on the dimmer used<br>
  16156. The attr subType must be gateway and gwCmd must be dimming. This is done if the device was
  16157. created by autocreate.<br>
  16158. For Eltako devices attributes must be set manually. Use the sensor type "PC/FVS" for Eltako devices.
  16159. </li>
  16160. <br><br>
  16161. <li>Gateway (EEP A5-38-08)<br>
  16162. Dimming of fluorescent lamps<br>
  16163. [Eltako FSG70, tested with Eltako FSG70 only]<br>
  16164. <ul>
  16165. <code>set &lt;name&gt; &lt;value&gt;</code>
  16166. <br><br>
  16167. where <code>value</code> is
  16168. <li>on<br>
  16169. issue switch on command</li>
  16170. <li>off<br>
  16171. issue switch off command</li>
  16172. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16173. </ul><br>
  16174. The attr subType must be gateway and gwCmd must be dimming. Set attr eventMap to B0:on BI:off,
  16175. attr subTypeSet to switch and attr switchMode to pushbutton manually.<br>
  16176. Use the sensor type "Richtungstaster" for Eltako devices.
  16177. </li>
  16178. <br><br>
  16179. <li>Gateway (EEP A5-38-08)<br>
  16180. Setpoint shift<br>
  16181. [untested]<br>
  16182. <ul>
  16183. <code>set &lt;name&gt; &lt;value&gt;</code>
  16184. <br><br>
  16185. where <code>value</code> is
  16186. <li>teach<br>
  16187. initiate teach-in mode</li>
  16188. <li>shift 1/K <br>
  16189. issue Setpoint shift</li>
  16190. </ul><br>
  16191. Shift Range: T = -12.7 K ... 12.8 K<br>
  16192. The attr subType must be gateway and gwCmd must be setpointShift.
  16193. This is done if the device was created by autocreate.<br>
  16194. </li>
  16195. <br><br>
  16196. <li>Gateway (EEP A5-38-08)<br>
  16197. Basic Setpoint<br>
  16198. [untested]<br>
  16199. <ul>
  16200. <code>set &lt;name&gt; &lt;value&gt;</code>
  16201. <br><br>
  16202. where <code>value</code> is
  16203. <li>teach<br>
  16204. initiate teach-in mode</li>
  16205. <li>basic t/&#176C<br>
  16206. issue Basic Setpoint</li>
  16207. </ul><br>
  16208. Setpoint Range: t = 0 &#176C ... 51.2 &#176C<br>
  16209. The attr subType must be gateway and gwCmd must be setpointBasic.
  16210. This is done if the device was created by autocreate.<br>
  16211. </li>
  16212. <br><br>
  16213. <li>Gateway (EEP A5-38-08)<br>
  16214. Control variable<br>
  16215. [untested]<br>
  16216. <ul>
  16217. <code>set &lt;name&gt; &lt;value&gt;</code>
  16218. <br><br>
  16219. where <code>value</code> is
  16220. <li>teach<br>
  16221. initiate teach-in mode</li>
  16222. <li>presence present|absent|standby<br>
  16223. issue Room occupancy</li>
  16224. <li>energyHoldOff normal|holdoff<br>
  16225. issue Energy hold off</li>
  16226. <li>controllerMode auto|heating|cooling|off<br>
  16227. issue Controller mode</li>
  16228. <li>controllerState auto|override <0 ... 100> <br>
  16229. issue Control variable override</li>
  16230. </ul><br>
  16231. Override Range: cvov = 0 % ... 100 %<br>
  16232. The attr subType must be gateway and gwCmd must be controlVar.
  16233. This is done if the device was created by autocreate.<br>
  16234. </li>
  16235. <br><br>
  16236. <li>Gateway (EEP A5-38-08)<br>
  16237. Fan stage<br>
  16238. [untested]<br>
  16239. <ul>
  16240. <code>set &lt;name&gt; &lt;value&gt;</code>
  16241. <br><br>
  16242. where <code>value</code> is
  16243. <li>teach<br>
  16244. initiate teach-in mode</li>
  16245. <li>stage 0 ... 3|auto<br>
  16246. issue Fan Stage override</li>
  16247. </ul><br>
  16248. The attr subType must be gateway and gwCmd must be fanStage.
  16249. This is done if the device was created by autocreate.<br>
  16250. </li>
  16251. <br><br>
  16252. <li>Gateway (EEP A5-38-08)<br>
  16253. <a name="Blind Command Central">Blind Command Central</a><br>
  16254. [not fully tested]<br>
  16255. <ul>
  16256. <code>set &lt;name&gt; &lt;value&gt;</code>
  16257. <br><br>
  16258. where <code>value</code> is
  16259. <li>position/% [&alpha;/&#176]<br>
  16260. drive blinds to position with angle value</li>
  16261. <li>teach<br>
  16262. initiate teach-in mode</li>
  16263. <li>status<br>
  16264. Status request</li>
  16265. <li>opens<br>
  16266. issue blinds opens command</li>
  16267. <li>up tu/s ta/s<br>
  16268. issue roll up command</li>
  16269. <li>closes<br>
  16270. issue blinds closes command</li>
  16271. <li>down td/s ta/s<br>
  16272. issue roll down command</li>
  16273. <li>position position/% [&alpha;/&#176]<br>
  16274. drive blinds to position with angle value</li>
  16275. <li>stop<br>
  16276. issue blinds stops command</li>
  16277. <li>runtimeSet tu/s td/s<br>
  16278. set runtime parameter</li>
  16279. <li>angleSet ta/s<br>
  16280. set angle configuration</li>
  16281. <li>positionMinMax positionMin/% positionMax/%<br>
  16282. set min, max values for position</li>
  16283. <li>angleMinMax &alpha;o/&#176 &alpha;s/&#176<br>
  16284. set slat angle for open and shut position</li>
  16285. <li>positionLogic normal|inverse<br>
  16286. set position logic</li>
  16287. </ul><br>
  16288. Runtime Range: tu|td = 0 s ... 255 s<br>
  16289. Select a runtime up and a runtime down that is at least as long as the
  16290. shading element or roller shutter needs to move from its end position to
  16291. the other position.<br>
  16292. Position Range: position = 0 % ... 100 %<br>
  16293. Angle Time Range: ta = 0 s ... 25.5 s<br>
  16294. Runtime value for the sunblind reversion time. Select the time to revolve
  16295. the sunblind from one slat angle end position to the other end position.<br>
  16296. Slat Angle: &alpha;|&alpha;o|&alpha;s = -180 &#176 ... 180 &#176<br>
  16297. Position Logic, normal: Blinds fully opens corresponds to Position = 0 %<br>
  16298. Position Logic, inverse: Blinds fully opens corresponds to Position = 100 %<br>
  16299. The attr subType must be gateway and gwCmd must be blindCmd.<br>
  16300. See also attributes <a href="#EnOcean_sendDevStatus">sendDevStatus and <a href="#EnOcean_serviceOn">serviceOn</a></a><br>
  16301. The profile is linked with controller profile, see <a href="#Blind Status">Blind Status</a>.<br>
  16302. </li>
  16303. <br><br>
  16304. <li>Extended Lighting Control (EEP A5-38-09)<br>
  16305. [untested]<br>
  16306. <ul>
  16307. <code>set &lt;name&gt; &lt;value&gt;</code>
  16308. <br><br>
  16309. where <code>value</code> is
  16310. <li>teach<br>
  16311. initiate remote teach-in</li>
  16312. <li>on<br>
  16313. issue switch on command</li>
  16314. <li>off<br>
  16315. issue switch off command</li>
  16316. <li>dim dim [rampTime/s]<br>
  16317. issue dim command</li>
  16318. <li>dimup rampTime/s<br>
  16319. issue dim command</li>
  16320. <li>dimdown rampTime/s<br>
  16321. issue dim command</li>
  16322. <li>stop<br>
  16323. stop dimming</li>
  16324. <li>rgb &lt;red color value&gt&lt;green color value&gt&lt;blue color value&gt<br>
  16325. issue color value command</li>
  16326. <li>scene drive|store 0..15<br>
  16327. store actual value in the scene or drive to scene value</li>
  16328. <li>dimMinMax &lt;min value&gt &lt;max value&gt<br>
  16329. set minimal and maximal dimmer value</li>
  16330. <li>lampOpHours 0..65535<br>
  16331. set the operation hours of the lamp</li>
  16332. <li>block unlock|on|off|local<br>
  16333. locking local operations</li>
  16334. <li>meteringValues 0..65535 mW|W|kW|MW|Wh|kWh|MWh|GWh|mA|mV<br>
  16335. set a new value for the energy metering (overwrite the actual value with the selected unit)</li>
  16336. <li>meteringValues 0..6553.5 A|V<br>
  16337. set a new value for the energy metering (overwrite the actual value with the selected unit)</li>
  16338. <li><a href="#setExtensions">set extensions</a> are supported.</li>
  16339. </ul><br>
  16340. color values: 00 ... FF hexadecimal<br>
  16341. rampTime Range: t = 1 s ... 65535 s or 1 if no time specified, ramping time can be set by attribute
  16342. <a href="#EnOcean_rampTime">rampTime</a><br>
  16343. The attr subType or subTypSet must be lightCtrl.01. This is done if the device was created by autocreate.<br>
  16344. The subType is associated with the subtype lightCtrlState.02.
  16345. </li>
  16346. <br><br>
  16347. <li><a name="Manufacturer Specific Applications">Manufacturer Specific Applications</a> (EEP A5-3F-7F)<br>
  16348. Shutter<br>
  16349. [Eltako FSB12, FSB14, FSB61, FSB70, tested with Eltako devices only]<br>
  16350. <ul>
  16351. <code>set &lt;name&gt; &lt;value&gt;</code>
  16352. <br><br>
  16353. where <code>value</code> is
  16354. <li>position/% [&alpha;/&#176]<br>
  16355. drive blinds to position with angle value</li>
  16356. <li>anglePos &alpha;/&#176<br>
  16357. drive blinds to angle value</li>
  16358. <li>closes<br>
  16359. issue blinds closes command</li>
  16360. <li>down td/s<br>
  16361. issue roll down command</li>
  16362. <li>opens<br>
  16363. issue blinds opens command</li>
  16364. <li>position position/% [&alpha;/&#176]<br>
  16365. drive blinds to position with angle value</li>
  16366. <li>stop<br>
  16367. issue stop command</li>
  16368. <li>teach<br>
  16369. initiate teach-in mode</li>
  16370. <li>up tu/s<br>
  16371. issue roll up command</li>
  16372. </ul><br>
  16373. Run-time Range: tu|td = 1 s ... 255 s<br>
  16374. Position Range: position = 0 % ... 100 %<br>
  16375. Slat Angle Range: &alpha; = -180 &#176 ... 180 &#176<br>
  16376. Angle Time Range: ta = 0 s ... 6 s<br>
  16377. The devive can only fully controlled if the attributes <a href="#angleMax">angleMax</a>,
  16378. <a href="#angleMin">angleMin</a>, <a href="#angleTime">angleTime</a>,
  16379. <a href="#shutTime">shutTime</a> and <a href="#shutTimeCloses">shutTimeCloses</a>,
  16380. are set correctly.
  16381. If <a href="#EnOcean_settingAccuracy">settingAccuracy</a> is set to high, the run-time is sent in 1/10 increments.<br>
  16382. Set attr subType to manufProfile, manufID to 00D and attr model to FSB14|FSB61|FSB70|TF manually.<br>
  16383. Use the sensor type "Szenentaster/PC" for Eltako devices.
  16384. </li>
  16385. <br><br>
  16386. <li>Electronic switches and dimmers with Energy Measurement and Local Control (D2-01-00 - D2-01-12)<br>
  16387. [Telefunken Funktionsstecker, PEHA Easyclick, AWAG Elektrotechnik AG Omnio UPS 230/xx,UPD 230/xx, NodOn in-wall module, smart plug]<br>
  16388. <ul>
  16389. <code>set &lt;name&gt; &lt;value&gt;</code>
  16390. <br><br>
  16391. where <code>value</code> is
  16392. <li>autoOffTime t/s [&lt;channel&gt;]<br>
  16393. set auto Off timer</li>
  16394. <li>delayOffTime t/s [&lt;channel&gt;]<br>
  16395. set delay Off timer</li>
  16396. <li>dim/% [&lt;channel&gt; [&lt;rampTime&gt;]]<br>
  16397. issue dimming command</li>
  16398. <li>extSwitchMode unavailable|switch|pushbutton|auto [&lt;channel&gt;]<br>
  16399. set external interface mode</li>
  16400. <li>extSwitchType toggle|direction [&lt;channel&gt;]<br>
  16401. set external interface type</li>
  16402. <li>on [&lt;channel&gt;]<br>
  16403. issue switch on command</li>
  16404. <li>off [&lt;channel&gt;]<br>
  16405. issue switch off command</li>
  16406. <li>dim dim/% [&lt;channel&gt; [&lt;rampTime&gt;]]<br>
  16407. issue dimming command</li>
  16408. <li>local dayNight day|night, day is default<br>
  16409. set the user interface indication</li>
  16410. <li>local defaultState on|off|last, off is default<br>
  16411. set the default setting of the output channels when switch on</li>
  16412. <li>local localControl enabled|disabled, disabled is default<br>
  16413. enable the local control of the device</li>
  16414. <li>local overCurrentShutdown off|restart, off is default<br>
  16415. set the behavior after a shutdown due to an overcurrent</li>
  16416. <li>local overCurrentShutdownReset not_active|trigger, not_active is default<br>
  16417. trigger a reset after an overcurrent</li>
  16418. <li>local rampTime&lt;1...3&gt; 0/s, 0.5/s ... 7/s, 7.5/s, 0 is default<br>
  16419. set the dimming time of timer 1 ... 3</li>
  16420. <li>local teachInDev enabled|disabled, disabled is default<br>
  16421. enable the taught-in devices with different EEP</li>
  16422. <li>measurement delta 0/s ... 4095/s, 0 is default<br>
  16423. define the difference between two displayed measurements </li>
  16424. <li>measurement mode energy|power, energy is default<br>
  16425. define the measurand</li>
  16426. <li>measurement report query|auto, query is default<br>
  16427. specify the measurement method</li>
  16428. <li>measurement reset not_active|trigger, not_active is default<br>
  16429. resetting the measured values</li>
  16430. <li>measurement responseTimeMax 10/s ... 2550/s, 10 is default<br>
  16431. set the maximum time between two outputs of measured values</li>
  16432. <li>measurement responseTimeMin 1/s ... 255/s, 1 is default<br>
  16433. set the minimum time between two outputs of measured values</li>
  16434. <li>measurement unit Ws|Wh|KWh|W|KW, Ws is default<br>
  16435. specify the measurement unit</li>
  16436. <li>roomCtrlMode off|comfort|comfort-1|comfort-2|economy|buildingProtection<br>
  16437. set pilot wire mode</li>
  16438. <li>special repeater off|1|2<br>
  16439. set repeater level of device (additional NodOn command)
  16440. </li>
  16441. </ul><br>
  16442. [autoOffTime] = 0 s ... 0.1 s ... 6553.4 s<br>
  16443. [delayOffTime] = 0 s ... 0.1 s ... 6553.4 s<br>
  16444. [channel] = 0...29|all|input, all is default<br>
  16445. The default channel can be specified with the attr <a href="#EnOcean_defaultChannel">defaultChannel</a>.<br>
  16446. [rampTime] = 1..3|switch|stop, switch is default<br>
  16447. The attr subType must be actuator.01. This is done if the device was
  16448. created by autocreate. To control the device, it must be bidirectional paired,
  16449. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16450. </li>
  16451. <br><br>
  16452. <li>Blind Control for Position and Angle (D2-05-00 - D2-05-01)<br>
  16453. [AWAG Elektrotechnik AG OMNIO UPJ 230/12, REGJ12/04M ]<br>
  16454. <ul>
  16455. <code>set &lt;name&gt; &lt;value&gt;</code>
  16456. <br><br>
  16457. where <code>value</code> is
  16458. <li>opens [&lt;channel&gt;]<br>
  16459. issue blinds opens command</li>
  16460. <li>closes [&lt;channel&gt;]<br>
  16461. issue blinds closes command</li>
  16462. <li>position position/% [[&alpha;/%] [[&lt;channel&gt;] [directly|opens|closes]]]<br>
  16463. drive blinds to position with angle value</li>
  16464. <li>anglePos &alpha;/% [&lt;channel&gt;]<br>
  16465. drive blinds to angle value</li>
  16466. <li>stop [&lt;channel&gt;]<br>
  16467. issue stop command</li>
  16468. <li>alarm [&lt;channel&gt;]<br>
  16469. set actuator to the "alarm" mode. When the actuator ist set to the "alarm" mode neither local
  16470. nor central positioning and configuration commands will be executed. Before entering the "alarm"
  16471. mode, the actuator will execute the "alarm action" as configured by the attribute <a href="#EnOcean_alarmAction">alarmAction</a>
  16472. </li>
  16473. <li>lock [&lt;channel&gt;]<br>
  16474. set actuator to the "blockade" mode. When the actuator ist set to the "blockade" mode neither local
  16475. nor central positioning and configuration commands will be executed.
  16476. </li>
  16477. <li>unlock [&lt;channel&gt;]<br>
  16478. issue unlock command</li>
  16479. </ul><br>
  16480. Channel Range: 1 ... 4|all, default is all<br>
  16481. Position Range: position = 0 % ... 100 %<br>
  16482. Slat Angle Range: &alpha; = 0 % ... 100 %<br>
  16483. The devive can only fully controlled if the attributes <a href="#EnOcean_alarmAction">alarmAction</a>,
  16484. <a href="#angleTime">angleTime</a>, <a href="#EnOcean_reposition">reposition</a> and <a href="#shutTime">shutTime</a>
  16485. are set correctly.<br>
  16486. With the attribute <a name="EnOcean_defaultChannel">defaultChannel</a> the default channel can be specified.<br>
  16487. The attr subType must be blindsCtrl.00 or blindsCtrl.01. This is done if the device was
  16488. created by autocreate. To control the device, it must be bidirectional paired,
  16489. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16490. </li>
  16491. <br><br>
  16492. <li>Multisensor Windows Handle (D2-06-01)<br>
  16493. [Soda GmbH]<br>
  16494. <ul>
  16495. <code>set &lt;name&gt; &lt;value&gt;</code>
  16496. <br><br>
  16497. where <code>value</code> is
  16498. <li>presence absent|present<br>
  16499. set vacation mode</li>
  16500. <li>handleClosedClick disable|enable<br>
  16501. set handle closed click feature</li>
  16502. <li>batteryLowClick disable|enable<br>
  16503. set battery low click feature</li>
  16504. <li>teachSlave contact|windowHandleClosed|windowHandleOpen|windowHandleTilted<br>
  16505. sent teach-in to the slave devices (contact: EEP: D5-00-01, windowHandle: EEP F6-10-00)<br>
  16506. The events window or handle will get forwarded once a slave-device contact or windowHandle is taught in.
  16507. </li>
  16508. <li>updateInterval t/s<br>
  16509. set sensor update interval</li>
  16510. <li>blinkInterval t/s<br>
  16511. set vacation blink interval</li>
  16512. </ul><br>
  16513. sensor update interval Range: updateInterval = 5 ... 65535<br>
  16514. vacation blick interval Range: blinkInterval = 3 ... 255<br>
  16515. The multisensor window handle is configured using the following attributes:<br>
  16516. <ul>
  16517. <li><a href="#EnOcean_subDefH">subDefH</a></li>
  16518. <li><a href="#EnOcean_subDefW">subDefW</a></li>
  16519. </ul>
  16520. The attr subType must be multisensor.01. This is done if the device was
  16521. created by autocreate.
  16522. </li>
  16523. <br><br>
  16524. <li>Room Control Panels (D2-10-00 - D2-10-02)<br>
  16525. [Kieback & Peter RBW322-FTL]<br>
  16526. <ul>
  16527. <code>set &lt;name&gt; &lt;value&gt;</code>
  16528. <br><br>
  16529. where <code>value</code> is
  16530. <li>buildingProtectionTemp t/&#176C<br>
  16531. set building protection temperature</li>
  16532. <li>clearCmds [&lt;channel&gt;]<br>
  16533. clear waiting commands</li>
  16534. <li>comfortTemp t/&#176C<br>
  16535. set comfort temperature</li>
  16536. <li>config<br>
  16537. Setting the configuration of the room controller, the configuration parameters are set using attributes.</li>
  16538. <li>cooling auto|off|on|no_change<br>
  16539. switch cooling</li>
  16540. <li>deleteTimeProgram<br>
  16541. delete time programs of the room controller</li>
  16542. <li>desired-temp t/&#176C<br>
  16543. set setpoint temperature</li>
  16544. <li>economyTemp t/&#176C<br>
  16545. set economy temperature</li>
  16546. <li>fanSpeed fanspeed/%<br>
  16547. set fan speed</li>
  16548. <li>fanSpeedMode central|local<br>
  16549. set fan speed mode</li>
  16550. <li>heating auto|off|on|no_change<br>
  16551. switch heating</li>
  16552. <li>preComfortTemp t/&#176C<br>
  16553. set pre comfort temperature</li>
  16554. <li>roomCtrlMode buildingProtectionTemp|comfortTemp|economyTemp|preComfortTemp<br>
  16555. select setpoint temperature</li>
  16556. <li>setpointTemp t/&#176C<br>
  16557. set current setpoint temperature</li>
  16558. <li>time<br>
  16559. set time and date of the room controller </li>
  16560. <li>timeProgram<br>
  16561. set time programms of the room contoller</li>
  16562. <li>window closed|open<br>
  16563. put the window state</li>
  16564. </ul><br>
  16565. Setpoint Range: t = 0 &#176C ... 40 &#176C<br>
  16566. The room controller is configured using the following attributes:<br>
  16567. <ul>
  16568. <li><a href="#EnOcean_blockDateTime">blockDateTime</a></li>
  16569. <li><a href="#EnOcean_blockDisplay">blockDisplay</a></li>
  16570. <li><a href="#EnOcean_blockFanSpeed">blockFanSpeed</a></li>
  16571. <li><a href="#EnOcean_blockMotion">blockMotion</a></li>
  16572. <li><a href="#EnOcean_blockProgram">blockProgram</a></li>
  16573. <li><a href="#EnOcean_blockOccupany">blockOccupancy</a></li>
  16574. <li><a href="#EnOcean_blockTemp">blockTemp</a></li>
  16575. <li><a href="#EnOcean_blockTimeProgram">blockTimeProgram</a></li>
  16576. <li><a href="#EnOcean_blockSetpointTemp">blockSetpointTemp</a></li>
  16577. <li><a href="#EnOcean_daylightSavingTime">daylightSavingTime</a></li>
  16578. <li><a href="#EnOcean_displayContent">displayContent</a></li>
  16579. <li><a href="#EnOcean_pollInterval">pollInterval</a></li>
  16580. <li><a href="#EnOcean_temperatureScale">temperatureScale</a></li>
  16581. <li><a href="#EnOcean_timeNotation">timeNotation</a></li>
  16582. <li><a href="#EnOcean_timeProgram[1-4]">timeProgram[1-4]</a></li>
  16583. </ul>
  16584. The attr subType must be roomCtrlPanel.00. 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>Room Control Panels (D2-11-01 - D2-11-08)<br>
  16590. [Thermokon EasySens SR06 LCD-2T/-2T rh -4T/-4T rh]<br>
  16591. <ul>
  16592. <code>set &lt;name&gt; &lt;value&gt;</code>
  16593. <br><br>
  16594. where <code>value</code> is
  16595. <li>cooling on|off, default [colling] = off<br>
  16596. set cooling symbol at the display</li>
  16597. <li>desired-temp t/&#176C<br>
  16598. set setpoint temperature</li>
  16599. <li>fanSpeed auto|off|1|2|3<br>
  16600. set fan speed</li>
  16601. <li>heating on|off, default [heating] = off<br>
  16602. set heating symbol at the display</li>
  16603. <li>occupancy occupied|unoccupied<br>
  16604. set occupancy state</li>
  16605. <li>setpointTemp t/&#176C<br>
  16606. set current setpoint temperature</li>
  16607. <li>setpointShiftMax t/K<br>
  16608. set setpoint shift max</li>
  16609. <li>setpointType setpointTemp|setpointShift<br>
  16610. set setpoint type</li>
  16611. <li>window closed|open, default [window] = closed<br>
  16612. set window open symbol at the display</li>
  16613. </ul><br>
  16614. Setpoint Range: t = 5 &#176C ... 40 &#176C<br>
  16615. Setpoint Shift Max Range: t = 0 K ... 10 K<br>
  16616. The attr subType must be roomCtrlPanel.01. This is done if the device was
  16617. created by autocreate. To control the device, it must be bidirectional paired by Smart Ack,
  16618. see <a href="#EnOcean_smartAck">SmartAck Learning</a>.
  16619. </li>
  16620. <br><br>
  16621. <li>Fan Control (D2-20-00 - D2-20-02)<br>
  16622. [Maico ECA x RC/RCH, ER 100 RC, untested]<br>
  16623. <ul>
  16624. <code>set &lt;name&gt; &lt;value&gt;</code>
  16625. <br><br>
  16626. where <code>value</code> is
  16627. <li>on<br>
  16628. fan on</li>
  16629. <li>off<br>
  16630. fan off</li>
  16631. <li>desired-temp [t/&#176C]<br>
  16632. set setpoint temperature</li>
  16633. <li>fanSpeed fanspeed/%|auto|default<br>
  16634. set fan speed</li>
  16635. <li>humidityThreshold rH/%<br>
  16636. set humidity threshold</li>
  16637. <li>roomSize 0...350/m<sup>2</sup>|default|not_used<br>
  16638. set room size</li>
  16639. <li>setpointTemp [t/&#176C]<br>
  16640. set current setpoint temperature</li>
  16641. </ul><br>
  16642. Setpoint Range: t = 0 &#176C ... 40 &#176C<br>
  16643. The fan controller is configured using the following attributes:<br>
  16644. <ul>
  16645. <li><a href="#EnOcean_setCmdTrigger">setCmdTrigger</a></li>
  16646. <li><a href="#EnOcean_switchHysteresis">switchHysteresis</a></li>
  16647. <li><a href="#temperatureRefDev">temperatureRefDev</a></li>
  16648. </ul>
  16649. The attr subType must be fanCtrl.00. This is done if the device was
  16650. created by autocreate. To control the device, it must be bidirectional paired,
  16651. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>. The profile
  16652. behaves like a master. Only one fan can be taught as a slave.
  16653. </li>
  16654. <br><br>
  16655. <li>Heat Recovery Ventilation (D2-50-00 - D2-50-11)<br>
  16656. [untested]<br>
  16657. <ul>
  16658. <code>set &lt;name&gt; &lt;value&gt;</code>
  16659. <br><br>
  16660. where <code>value</code> is
  16661. <li>ventilation off|1...4|auto|demand|supplyAir|exhaustAir<br>
  16662. select ventilation mode/level</li>
  16663. <li>heatExchangerBypass opens|closes<br>
  16664. override of automatic heat exchanger bypass control</li>
  16665. <li>startTimerMode<br>
  16666. enable timer operation mode</li>
  16667. <li>CO2Threshold default|1/%<br>
  16668. override CO2 threshold for CO2 control in automatic mode</li>
  16669. <li>humidityThreshold default|rH/%<br>
  16670. override humidity threshold for humidity control in automatic mode</li>
  16671. <li>airQuatityThreshold default|1/%<br>
  16672. override air qualidity threshold for air qualidity control in automatic mode</li>
  16673. <li>roomTemp default|t/&#176C<br>
  16674. override room temperature threshold for room temperature control mode</li>
  16675. </ul><br>
  16676. roomTemp Range: t = -63 &#176C ... 63 &#176C<br>
  16677. xThreshold Range: 0 % ... 100 %<br>
  16678. The attr subType must be heatRecovery.00. This is done if the device was
  16679. created by autocreate. To control the device, it must be bidirectional paired,
  16680. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16681. </li>
  16682. <br><br>
  16683. <li>Valve Control (EEP D2-A0-01)<br>
  16684. <ul>
  16685. <code>set &lt;name&gt; &lt;value&gt;</code>
  16686. <br><br>
  16687. where <code>value</code> is
  16688. <li>closes<br>
  16689. issue closes command (master)</li>
  16690. <li>opens<br>
  16691. issue opens command (master)</li>
  16692. <li>closed<br>
  16693. issue closed command (slave)</li>
  16694. <li>open<br>
  16695. issue open command (slave)</li>
  16696. <li>teachIn<br>
  16697. initiate UTE teach-in (slave)</li>
  16698. <li>teachOut<br>
  16699. initiate UTE teach-out (slave)</li>
  16700. </ul><br>
  16701. The valve controller is configured using the following attributes:<br>
  16702. <ul>
  16703. <li><a href="#EnOcean_devMode">devMode</a></li>
  16704. </ul>
  16705. The attr subType must be valveCtrl.00. This is done if the device was
  16706. created by autocreate. To control the device, it must be bidirectional paired,
  16707. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>. The profile
  16708. behaves like a master or slave, see <a href="#EnOcean_devMode">devMode</a>.
  16709. </li>
  16710. <br><br>
  16711. <li>Generic Profiles<br>
  16712. <ul>
  16713. <code>set &lt;name&gt; &lt;value&gt;</code>
  16714. <br><br>
  16715. where <code>value</code> is
  16716. <li>&lt;00 ... 64&gt;-&lt;channel name&gt; &lt;value&gt;<br>
  16717. set channel value</li>
  16718. <li>channelName &lt;channel number&gt;-&lt;channel name&gt;<br>
  16719. rename channel</li>
  16720. <li>teachIn<br>
  16721. sent teach-in telegram</li>
  16722. <li>teachOut<br>
  16723. sent teach-out telegram</li>
  16724. </ul><br>
  16725. The generic profile device is configured using the following attributes:<br>
  16726. <ul>
  16727. <li><a href="#EnOcean_comMode">comMode</a></li>
  16728. <li><a href="#EnOcean_devMode">devMode</a></li>
  16729. <li><a href="#EnOcean_gpDef">gpDef</a></li>
  16730. <li><a href="#EnOcean_manufID">manufID</a></li>
  16731. </ul>
  16732. The attr subType must be genericProfile. This is done if the device was
  16733. created by autocreate. If the profile in slave mode is operated, especially the channel
  16734. definition in the gpDef attributes must be entered manually.
  16735. </li>
  16736. <br><br>
  16737. <li>RAW Command<br>
  16738. <ul>
  16739. <code>set &lt;name&gt; &lt;value&gt;</code>
  16740. <br><br>
  16741. where <code>value</code> is
  16742. <li>1BS|4BS|GPCD|GPSD|GPTI|GPTR|MSC|RPS|UTE|VLD data [status]<br>
  16743. sent data telegram</li>
  16744. </ul><br>
  16745. [data] = &lt;1-byte hex ... 512-byte hex&gt;<br>
  16746. [status] = 0x00 ... 0xFF<br>
  16747. With the help of this command data messages in hexadecimal format can be sent.
  16748. Telegram types (RORG) 1BS, 4BS, RPS, MSC, UTE, VLD, GPCD, GPSD, GPTI and GPTR are supported.
  16749. For further information, see <a href="http://www.enocean-alliance.org/eep/">EnOcean Equipment Profiles (EEP)</a> and
  16750. Generic Profiles.
  16751. </li>
  16752. <br><br>
  16753. <li>Radio Link Test<br>
  16754. <ul>
  16755. <code>set &lt;name&gt; &lt;value&gt;</code>
  16756. <br><br>
  16757. where <code>value</code> is
  16758. <li>standby|stop<br>
  16759. set RLT Master state
  16760. </li>
  16761. </ul><br>
  16762. The Radio Link Test device is configured using the following attributes:<br>
  16763. <ul>
  16764. <li><a href="#EnOcean_rltRepeat">rltRepeat</a></li>
  16765. <li><a href="#EnOcean_rltType">rltType</a></li>
  16766. </ul>
  16767. The attr subType must be readioLinkTest. This is done if the device was
  16768. created by autocreate or manually by <code>define &lt;name&gt; EnOcean A5-3F-00</code><br>.
  16769. </li>
  16770. <br><br>
  16771. </ul></ul>
  16772. <a name="EnOceanget"></a>
  16773. <b>Get</b>
  16774. <ul>
  16775. <li><a name="EnOcean_remoteGet">Remote Management</a>
  16776. <ul>
  16777. <code>get &lt;name&gt; &lt;value&gt;</code>
  16778. <br><br>
  16779. where <code>value</code> is
  16780. <li>remoteDevCfg &lt;start data index&gt; &lt;end data index&gt;<br>
  16781. get device configuration between start index and end index</li>
  16782. <li>remoteFunctions<br>
  16783. get a list of the supported extended functions</li>
  16784. <li>remoteID<br>
  16785. get the remote device ID</li>
  16786. <li>remoteLinkTableInfo<br>
  16787. query supported link table info</li>
  16788. <li>remoteLinkCfg in|out &lt;index&gt; &lt;start data index&gt; &lt;end data index&gt; &lt;length&gt;<br>
  16789. get link table between start index and end index</li>
  16790. <li>remoteLinkTable in|out &lt;start index&gt; &lt;end index&gt;<br>
  16791. get link table between start index and end index</li>
  16792. <li>remoteLinkTableGP in|out &lt;index&gt;<br>
  16793. get link table GP entry with index</li>
  16794. <li>remotePing<br>
  16795. get a ping response from the remote device</li>
  16796. <li>remoteProductID<br>
  16797. query product ID</li>
  16798. <li>remoteRepeater<br>
  16799. asks for the repeater status of the remote device</li>
  16800. <li>remoteStatus<br>
  16801. asks for the status info of the remote device</li>
  16802. <br>
  16803. [&lt;data index&gt;] = 0000...FFFF<br>
  16804. [&lt;index&gt;] = 00...FF<br>
  16805. [&lt;length&gt;] = n x 00...FF<br>
  16806. </ul>
  16807. </li><br><br>
  16808. <li>Dual Channel Switch Actuator (EEP A5-11-059)<br>
  16809. [untested]<br>
  16810. <ul>
  16811. <code>get &lt;name&gt; &lt;value&gt;</code>
  16812. <br><br>
  16813. where <code>value</code> is
  16814. <li>state<br>
  16815. status request</li>
  16816. </ul><br>
  16817. The attr subType or subTypSet must be switch.05. This is done if the device was created by autocreate.
  16818. </li>
  16819. <br><br>
  16820. <li>Extended Lighting Control (EEP A5-38-09)<br>
  16821. [untested]<br>
  16822. <ul>
  16823. <code>get &lt;name&gt; &lt;value&gt;</code>
  16824. <br><br>
  16825. where <code>value</code> is
  16826. <li>state<br>
  16827. status request</li>
  16828. </ul><br>
  16829. The attr subType or subTypSet must be lightCtrl.01. This is done if the device was created by autocreate.<br>
  16830. The subType is associated with the subtype lightCtrlState.02.
  16831. </li>
  16832. <br><br>
  16833. <li>Electronic switches and dimmers with Energy Measurement and Local Control (D2-01-00 - D2-01-12)<br>
  16834. [Telefunken Funktionsstecker, PEHA Easyclick, AWAG Elektrotechnik AG Omnio UPS 230/xx,UPD 230/xx, NodOn in-wall module, smart plug]<br>
  16835. <ul>
  16836. <code>get &lt;name&gt; &lt;value&gt;</code>
  16837. <br><br>
  16838. where <code>value</code> is
  16839. <li>roomCtrlMode<br>
  16840. get pilot wire mode</li>
  16841. <li>settings [&lt;channel&gt;]<br>
  16842. get external interface settings</li>
  16843. <li>state [&lt;channel&gt;]<br>
  16844. </li>
  16845. <li>measurement &lt;channel&gt; energy|power<br>
  16846. </li>
  16847. <li>special &lt;channel&gt; health|load|voltage|serialNumber<br>
  16848. additional Permondo SmartPlug PSC234 commands
  16849. </li>
  16850. <li>special &lt;channel&gt; firmwareVersion|reset|taughtInDevID|taughtInDevNum<br>
  16851. additional NodOn commands
  16852. </li>
  16853. </ul><br>
  16854. The default channel can be specified with the attr <a href="#EnOcean_defaultChannel">defaultChannel</a>.<br>
  16855. The attr subType must be actuator.01. This is done if the device was
  16856. created by autocreate. To control the device, it must be bidirectional paired,
  16857. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16858. </li>
  16859. <br><br>
  16860. <li>Blind Control for Position and Angle (D2-05-00)<br>
  16861. [AWAG Elektrotechnik AG OMNIO UPJ 230/12, REGJ12/04M]<br>
  16862. <ul>
  16863. <code>get &lt;name&gt; &lt;value&gt;</code>
  16864. <br><br>
  16865. where <code>value</code> is
  16866. <li>position [&lt;channel&gt;]<br>
  16867. query position and angle value</li>
  16868. </ul><br>
  16869. Channel Range: 1 ... 4|all, default is all<br>
  16870. The devive can only fully controlled if the attributes <a href="#EnOcean_alarmAction">alarmAction</a>,
  16871. <a href="#angleTime">angleTime</a>, <a href="#EnOcean_reposition">reposition</a> and <a href="#shutTime">shutTime</a>
  16872. are set correctly.<br>
  16873. With the attribute <a name="EnOcean_defaultChannel">defaultChannel</a> the default channel can be specified.<br>
  16874. The attr subType must be blindsCtrl.00 or blindsCrtl.01. This is done if the device was
  16875. created by autocreate. To control the device, it must be bidirectional paired,
  16876. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16877. </li>
  16878. <br><br>
  16879. <li>Multisensor Windows Handle (D2-06-01)<br>
  16880. [Soda GmbH]<br>
  16881. <ul>
  16882. <code>get &lt;name&gt; &lt;value&gt;</code>
  16883. <br><br>
  16884. where <code>value</code> is
  16885. <li>config<br>
  16886. get configuration settings</li>
  16887. <li>log<br>
  16888. get log data</li>
  16889. </ul><br>
  16890. The multisensor window handle is configured using the following attributes:<br>
  16891. <ul>
  16892. <li><a href="#EnOcean_subDefH">subDefH</a></li>
  16893. <li><a href="#EnOcean_subDefW">subDefW</a></li>
  16894. </ul>
  16895. The attr subType must be multisensor.01. This is done if the device was
  16896. created by autocreate.
  16897. </li>
  16898. <br><br>
  16899. <li>Room Control Panels (D2-10-00 - D2-10-02)<br>
  16900. [Kieback & Peter RBW322-FTL]<br>
  16901. <ul>
  16902. <code>get &lt;name&gt; &lt;value&gt;</code>
  16903. <br><br>
  16904. where <code>value</code> is
  16905. <li>config<br>
  16906. get the configuration of the room controler</li>
  16907. <li>data<br>
  16908. get data</li>
  16909. <li>roomCtrl<br>
  16910. get the parameter of the room controler</li>
  16911. <li>timeProgram<br>
  16912. get the time program</li>
  16913. </ul><br>
  16914. The attr subType must be roomCtrlPanel.00. This is done if the device was
  16915. created by autocreate. To control the device, it must be bidirectional paired,
  16916. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16917. </li>
  16918. <br><br>
  16919. <li>Fan Control (D2-20-00 - D2-20-02)<br>
  16920. [Maico ECA x RC/RCH, ER 100 RC, untested]<br>
  16921. <ul>
  16922. <code>get &lt;name&gt; &lt;value&gt;</code>
  16923. <br><br>
  16924. where <code>value</code> is
  16925. <li>state<br>
  16926. get the state of the room controler</li>
  16927. </ul><br>
  16928. The attr subType must be fanCtrl.00. This is done if the device was
  16929. created by autocreate. To control the device, it must be bidirectional paired,
  16930. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16931. </li>
  16932. <br><br>
  16933. <li>Heat Recovery Ventilation (D2-50-00 - D2-50-11)<br>
  16934. [untested]<br>
  16935. <ul>
  16936. <code>get &lt;name&gt; &lt;value&gt;</code>
  16937. <br><br>
  16938. where <code>value</code> is
  16939. <li>basicState<br>
  16940. get the basic state</li>
  16941. <li>extendedState<br>
  16942. get the extended state</li>
  16943. </ul><br>
  16944. The attr subType must be heatRecovery.00. This is done if the device was
  16945. created by autocreate. To control the device, it must be bidirectional paired,
  16946. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  16947. </li>
  16948. <br><br>
  16949. <li>Valve Control (EEP D2-A0-01)<br>
  16950. <ul>
  16951. <code>get &lt;name&gt; &lt;value&gt;</code>
  16952. <br><br>
  16953. where <code>value</code> is
  16954. <li>state<br>
  16955. get the state of the valve controler (master)</li>
  16956. </ul><br>
  16957. The attr subType must be valveCtrl.00. This is done if the device was
  16958. created by autocreate. To control the device, it must be bidirectional paired,
  16959. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>. The profile
  16960. behaves like a master or slave, see <a href="#EnOcean_devMode">devMode</a>.
  16961. </li>
  16962. <br><br>
  16963. </ul><br>
  16964. <a name="EnOceanattr"></a>
  16965. <b>Attributes</b>
  16966. <ul>
  16967. <ul>
  16968. <li><a name="actualTemp">actualTemp</a> t/&#176C<br>
  16969. The value of the actual temperature, used by a Room Sensor and Control Unit
  16970. or when controlling HVAC components e. g. Battery Powered Actuators (MD15 devices). Should by
  16971. filled via a notify from a distinct temperature sensor.<br>
  16972. If absent, the reported temperature from the HVAC components is used.
  16973. </li>
  16974. <li><a name="EnOcean_alarmAction">alarmAction</a> &lt;channel1&gt;[:&lt;channel2&gt;[:&lt;channel3&gt;[:&lt;channel4&gt;]]]<br>
  16975. [alarmAction] = no|stop|opens|closes, default is no<br>
  16976. Action that is executed before the actuator is entering the "alarm" mode.<br>
  16977. Notice subType blindsCrtl.00, blindsCrtl.01: The attribute can only be set while the actuator is online.
  16978. </li>
  16979. <li><a name="angleMax">angleMax</a> &alpha;s/&#176, [&alpha;s] = -180 ... 180, 90 is default.<br>
  16980. Slat angle end position maximum.<br>
  16981. angleMax is supported for shutter.
  16982. </li>
  16983. <li><a name="angleMin">angleMin</a> &alpha;o/&#176, [&alpha;o] = -180 ... 180, -90 is default.<br>
  16984. Slat angle end position minimum.<br>
  16985. angleMin is supported for shutter.
  16986. </li>
  16987. <li><a name="angleTime">angleTime</a> &lt;channel1&gt;[:&lt;channel2&gt;[:&lt;channel3&gt;[:&lt;channel4&gt;]]]<br>
  16988. subType blindsCtrl.00, blindsCtrl.01: [angleTime] = 0|0.01 .. 2.54, 0 is default.<br>
  16989. subType manufProfile: [angleTime] = 0 ... 6, 0 is default.<br>
  16990. Runtime value for the sunblind reversion time. Select the time to revolve
  16991. the sunblind from one slat angle end position to the other end position.<br>
  16992. Notice subType blindsCrtl.00: The attribute can only be set while the actuator is online.
  16993. </li>
  16994. <li><a name="EnOcean_blockDateTime">blockDateTime</a> yes|no, [blockDateTime] = no is default.<br>
  16995. blockDateTime is supported for roomCtrlPanel.00.
  16996. </li>
  16997. <li><a name="EnOcean_blockDisplay">blockDisplay</a> yes|no, [blockDisplay] = no is default.<br>
  16998. blockDisplay is supported for roomCtrlPanel.00.
  16999. </li>
  17000. <li><a name="EnOcean_blockFanSpeed">blockFanSpeed</a> yes|no, [blockFanSpeed] = no is default.<br>
  17001. blockFanSpeed is supported for roomCtrlPanel.00.
  17002. </li>
  17003. <li><a name="EnOcean_blockKey">blockKey</a> yes|no, [blockKey] = no is default.<br>
  17004. blockKey is supported for roomCtrlPanel.00 and hvac.04.
  17005. </li>
  17006. <li><a name="EnOcean_blockMotion">blockMotion</a> yes|no, [blockMotion] = no is default.<br>
  17007. blockMotion is supported for roomCtrlPanel.00.
  17008. </li>
  17009. <li><a name="EnOcean_blockOccupany">blockOccupancy</a> yes|no, [blockOccupancy] = no is default.<br>
  17010. blockOccupancy is supported for roomCtrlPanel.00.
  17011. </li>
  17012. <li><a name="EnOcean_blockTemp">blockTemp</a> yes|no, [blockTemp] = no is default.<br>
  17013. blockTemp is supported for roomCtrlPanel.00.
  17014. </li>
  17015. <li><a name="EnOcean_blockTimeProgram">blockTimeProgram</a> yes|no, [blockTimeProgram] = no is default.<br>
  17016. blockTimeProgram is supported for roomCtrlPanel.00.
  17017. </li>
  17018. <li><a name="EnOcean_blockSetpointTemp">blockSetpointTemp</a> yes|no, [blockSetpointTemp] = no is default.<br>
  17019. blockSetPointTemp is supported for roomCtrlPanel.00.
  17020. </li>
  17021. <li><a name="EnOcean_blockUnknownMSC">blockUnknownMSC</a> yes|no,
  17022. [blockUnknownMSC] = no is default.<br>
  17023. If the structure of the MSC telegrams can not interpret the raw data to be output. Setting this attribute to yes,
  17024. the output can be suppressed.
  17025. </li>
  17026. <li><a name="EnOcean_comMode">comMode</a> biDir|confirm|uniDir, [comMode] = uniDir is default.<br>
  17027. Communication Mode between an enabled EnOcean device and Fhem.<br>
  17028. Unidirectional communication means a point-to-multipoint communication
  17029. relationship. The EnOcean device e. g. sensors does not know the unique
  17030. Fhem SenderID.<br>
  17031. If the attribute is set to confirm Fhem awaits confirmation telegrams from the remote device.<br>
  17032. Bidirectional communication means a point-to-point communication
  17033. relationship between an enabled EnOcean device and Fhem. It requires all parties
  17034. involved to know the unique Sender ID of their partners. Bidirectional communication
  17035. needs a teach-in / teach-out process, see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  17036. </li>
  17037. <li><a name="EnOcean_dataEnc">dataEnc</a> VAES|AES-CBC, [dataEnc] = VAES is default<br>
  17038. Data encryption algorithm
  17039. </li>
  17040. <li><a name="EnOcean_defaultChannel">defaultChannel</a> &lt;channel&gt;
  17041. subType actuator.01: [defaultChannel] = all|input|0 ... 29, all is default.<br>
  17042. subType blindsCtrl.00, blindsCtrl.01: [defaultChannel] = all|1 ... 4, all is default.<br>
  17043. Default device channel
  17044. </li>
  17045. <li><a name="EnOcean_daylightSavingTime">daylightSavingTime</a> supported|not_supported, [daylightSavingTime] = supported is default.<br>
  17046. daylightSavingTime is supported for roomCtrlPanel.00.
  17047. </li>
  17048. <li><a name="EnOcean_demandRespAction">demandRespAction</a> &lt;command&gt;<br>
  17049. Command being executed after an demand response command is set. If &lt;command&gt; is enclosed in {},
  17050. then it is a perl expression, if it is enclosed in "", then it is a shell command,
  17051. else it is a "plain" fhem.pl command (chain). In the &lt;command&gt; you can access the demand response
  17052. readings $TYPE, $NAME, $LEVEL, $SETPOINT, $POWERUSAGE, $POWERUSAGESCALE, $POWERUSAGELEVEL, $STATE. In addition,
  17053. the variables $TARGETNAME, $TARGETTYPE, $TARGETSTATE can be used if the action is executed
  17054. on the target device. This data is available as a local variable in perl, as environment variable for shell
  17055. scripts, and will be textually replaced for Fhem commands.
  17056. </li>
  17057. <li><a name="EnOcean_demandRespMax">demandRespMax</a> A0|AI|B0|BI|C0|CI|D0|DI, [demandRespMax] = B0 is default<br>
  17058. Switch command which is executed if the demand response switches to a maximum.
  17059. </li>
  17060. <li><a name="EnOcean_demandRespMin">demandRespMin</a> A0|AI|B0|BI|C0|CI|D0|DI, [demandRespMax] = BI is default<br>
  17061. Switch command which is executed if the demand response switches to a minimum.
  17062. </li>
  17063. <li><a name="EnOcean_demandRespRefDev">demandRespRefDev</a> &lt;name&gt;<br>
  17064. </li>
  17065. <li><a name="EnOcean_demandRespRandomTime">demandRespRandomTime</a> t/s [demandRespRandomTime] = 1 is default<br>
  17066. Maximum length of the random delay at the start or end of a demand respose event in slave mode.
  17067. </li>
  17068. <li><a name="EnOcean_demandRespThreshold">demandRespThreshold</a> 0...15 [demandRespTheshold] = 8 is default<br>
  17069. Threshold for switching the power usage level between minimum and maximum in the master mode.
  17070. </li>
  17071. <li><a name="EnOcean_demandRespTimeoutLevel">demandRespTimeoutLevel</a> max|last [demandRespTimeoutLevel] = max is default<br>
  17072. Demand response timeout level in slave mode.
  17073. </li>
  17074. <li><a name="devChannel">devChannel</a> 00 ... FF, [devChannel] = FF is default<br>
  17075. Number of the individual device channel, FF = all channels supported by the device
  17076. </li>
  17077. <li><a name="destinationID">destinationID</a> multicast|unicast|00000001 ... FFFFFFFF,
  17078. [destinationID] = multicast is default<br>
  17079. Destination ID, special values: multicast = FFFFFFFF, unicast = [DEF]
  17080. </li>
  17081. <li><a name="EnOcean_devMode">devMode</a> master|slave, [devMode] = master is default.<br>
  17082. device operation mode.
  17083. </li>
  17084. <li><a href="#devStateIcon">devStateIcon</a></li>
  17085. <li><a name="EnOcean_dimMax">dimMax</a> dim/%|off, [dimMax] = 255 is default.<br>
  17086. maximum brightness value<br>
  17087. dimMax is supported for the profile gateway/dimming.
  17088. </li>
  17089. <li><a name="EnOcean_dimMin">dimMin</a> dim/%|off, [dimMax] = off is default.<br>
  17090. minimum brightness value<br>
  17091. If [dimMax] = off, then the actuator takes down the ramp time set there.
  17092. dimMin is supported for the profile gateway/dimming.
  17093. </li>
  17094. <li><a name="dimValueOn">dimValueOn</a> dim/%|last|stored,
  17095. [dimValueOn] = 100 is default.<br>
  17096. Dim value for the command "on".<br>
  17097. The dimmer switched on with the value 1 % ... 100 % if [dimValueOn] =
  17098. 1 ... 100.<br>
  17099. The dimmer switched to the last dim value received from the
  17100. bidirectional dimmer if [dimValueOn] = last.<br>
  17101. The dimmer switched to the last Fhem dim value if [dimValueOn] =
  17102. stored.<br>
  17103. dimValueOn is supported for the profile gateway/dimming.
  17104. </li>
  17105. <li><a href="#EnOcean_disable">disable</a> 0|1<br>
  17106. If applied set commands will not be executed.
  17107. </li>
  17108. <li><a href="#EnOcean_disabledForIntervals">disabledForIntervals</a> HH:MM-HH:MM HH:MM-HH-MM...<br>
  17109. Space separated list of HH:MM tupels. If the current time is between
  17110. the two time specifications, set commands will not be executed. Instead of
  17111. HH:MM you can also specify HH or HH:MM:SS. To specify an interval
  17112. spawning midnight, you have to specify two intervals, e.g.:
  17113. <ul>
  17114. 23:00-24:00 00:00-01:00
  17115. </ul>
  17116. </li>
  17117. <li><a name="EnOcean_displayContent">displayContent</a>
  17118. humidity|off|setpointTemp|temperatureExtern|temperatureIntern|time|default|no_change, [displayContent] = no_change is default.<br>
  17119. displayContent is supported for roomCtrlPanel.00.
  17120. </li>
  17121. <li><a name="EnOcean_displayOrientation">displayOrientation</a> rad/&#176, [displayOrientation] = 0|90|180|270, 0 is default.<br>
  17122. Display orientation of the actuator
  17123. </li>
  17124. <li><a href="#do_not_notify">do_not_notify</a></li>
  17125. <li><a name="EnOcean_eep">eep</a> &lt;00...FF&gt;-&lt;00...3F&gt;-&lt;00...7F&gt;<br>
  17126. EnOcean Equipment Profile (EEP)
  17127. <li><a href="#eventMap">eventMap</a></li>
  17128. </li>
  17129. <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;]] ...
  17130. &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;]]
  17131. <br>
  17132. Generic Profiles channel definitions are set automatically in master mode. If the profile in slave mode is operated, the channel
  17133. definition must be entered manually. For each channel, the channel definitions are to be given in ascending order. The channel
  17134. parameters to be specified in decimal. First, the outgoing channels (direction = O) are to be defined, then the incoming channels
  17135. (direction = I) should be described. The channel numbers are assigned automatically starting with 00th.
  17136. </li>
  17137. <li><a name="gwCmd">gwCmd</a> switching|dimming|setpointShift|setpointBasic|controlVar|fanStage|blindCmd<br>
  17138. Gateway Command Type, see <a href="#Gateway">Gateway</a> profile
  17139. </li>
  17140. <li><a name="EnOcean_humidity">humidity</a> rH/%<br>
  17141. The value of the actual humidity, used by a Room Sensor and Control Unit. Should by
  17142. filled via a notify from a distinct humidity sensor.
  17143. </li>
  17144. <li><a name="EnOcean_humidityRefDev">humidityRefDev</a> &lt;name&gt;<br>
  17145. Name of the device whose reference value is read. The reference values is
  17146. the reading humidity.
  17147. </li>
  17148. <li><a href="#ignore">ignore</a></li>
  17149. <li><a href="#IODev">IODev</a></li>
  17150. <li><a name="EnOcean_keyRcv">keyRcv</a> &lt;private key 16 byte hex&gt;<br>
  17151. Private Key for receive direction
  17152. </li>
  17153. <li><a name="EnOcean_keySnd">keySnd</a> &lt;private key 16 byte hex&gt;<br>
  17154. Private Key for send direction
  17155. </li>
  17156. <li><a name="EnOcean_macAlgo">macAlgo</a> no|3|4<br>
  17157. MAC Algorithm
  17158. </li>
  17159. <li><a name="EnOcean_manufID">manufID</a> &lt;000 ... 7FF&gt;<br>
  17160. Manufacturer ID number
  17161. </li>
  17162. <li><a name="EnOcean_measurementCtrl">measurementCtrl</a> enable|disable<br>
  17163. Enable or disable the temperature measurements (room and feed temperature) of the actuator. If the temperature
  17164. measurements are turned off, an external temperature sensor must be exists, see attribute
  17165. <a href="#temperatureRefDev">temperatureRefDev</a>.
  17166. </li>
  17167. <li><a href="#model">model</a></li>
  17168. <li><a name="EnOcean_observe">observe</a> off|on, [observe] = off is default.<br>
  17169. Observing and repeating the execution of set commands
  17170. </li>
  17171. <li><a name="EnOcean_observeCmdRepetition">observeCmdRepetition</a> 1..5, [observeCmdRepetition] = 2 is default.<br>
  17172. Maximum number of command retries
  17173. </li>
  17174. <li><a name="EnOcean_observeErrorAction">observeErrorAction</a> &lt;command&gt;<br>
  17175. Command being executed after an error. If &lt;command&gt; is enclosed in {},
  17176. then it is a perl expression, if it is enclosed in "", then it is a shell command,
  17177. else it is a "plain" fhem.pl command (chain). In the &lt;command&gt; you can access the set
  17178. command. $TYPE, $NAME, $FAILEDDEV, $EVENT, $EVTPART0, $EVTPART1, $EVTPART2, etc. contains the space separated
  17179. set parts. The <a href="#eventMap">eventMap</a> replacements are taken into account. This data
  17180. is available as a local variable in perl, as environment variable for shell
  17181. scripts, and will be textually replaced for Fhem commands.
  17182. </li>
  17183. <li><a name="EnOcean_observeInterval">observeInterval</a> 1/s ... 255/s, [observeInterval] = 1 is default.<br>
  17184. Interval between two observations
  17185. </li>
  17186. <li><a name="EnOcean_observeLogic">observeLogic</a> and|or, [observeLogic] = or is default.<br>
  17187. Observe logic
  17188. </li>
  17189. <li><a name="EnOcean_observeRefDev">observeRefDev</a> &lt;name&gt; [&lt;name&gt; [&lt;name&gt;]],
  17190. [observeRefDev] = &lt;name of the own device&gt; is default<br>
  17191. Names of the devices to be observed. The list must be separated by spaces.
  17192. </li>
  17193. <li><a name="EnOcean_pidActorCallBeforeSetting">pidActorCallBeforeSetting</a>,
  17194. [pidActorCallBeforeSetting] = not defined is default<br>
  17195. Callback-function, which can manipulate the actorValue. Further information see modul PID20.
  17196. </li>
  17197. <li><a name="EnOcean_pidActorErrorAction">pidActorErrorAction</a> freeze|errorPos,
  17198. [pidActorErrorAction] = freeze is default<br>
  17199. required action on error
  17200. </li>
  17201. <li><a name="EnOcean_pidActorErrorPos">pidActorErrorPos</a> valvePos/%,
  17202. [pidActorErrorPos] = 0...100, 0 is default<br>
  17203. actor's position to be used in case of error
  17204. </li>
  17205. <li><a name="EnOcean_pidActorLimitLower">pidActorLimitLower</a> valvePos/%,
  17206. [pidActorLimitLower] = 0...100, 0 is default<br>
  17207. lower limit for actor
  17208. </li>
  17209. <li><a name="EnOcean_pidActorLimitUpper">pidActorLimitUpper</a> valvePos/%,
  17210. [pidActorLimitUpper] = 0...100, 100 is default<br>
  17211. upper limit for actor
  17212. </li>
  17213. <li><a name="EnOcean_pidCtrl">pidCtrl</a> on|off,
  17214. [pidCtrl] = on is default<br>
  17215. Activate the Fhem PID regulator
  17216. </li>
  17217. <li><a name="EnOcean_pidDeltaTreshold">pidDeltaTreshold</a> &lt;floating-point number&gt;,
  17218. [pidDeltaTreshold] = 0 is default<br>
  17219. if delta < delta-threshold the pid will enter idle state
  17220. </li>
  17221. <li><a name="EnOcean_pidFactor_P">pidFactor_P</a> &lt;floating-point number&gt;,
  17222. [pidFactor_P] = 25 is default<br>
  17223. P value for PID
  17224. </li>
  17225. <li><a name="EnOcean_pidFactor_I">pidFactor_I</a> &lt;floating-point number&gt;,
  17226. [pidFactor_I] = 0.25 is default<br>
  17227. I value for PID
  17228. </li>
  17229. <li><a name="EnOcean_pidFactor_D">pidFactor_D</a> &lt;floating-point number&gt;,
  17230. [pidFactor_D] = 0 is default<br>
  17231. D value for PID
  17232. </li>
  17233. <li><a name="EnOcean_pidIPortionCallBeforeSetting">pidIPortionCallBeforeSetting</a>
  17234. [pidIPortionCallBeforeSetting] = not defined is default<br>
  17235. Callback-function, which can manipulate the value of I-Portion. Further information see modul PID20.
  17236. </li>
  17237. <li><a name="EnOcean_pidSensorTimeout">pidSensorTimeout t/s</a>
  17238. [pidSensorTimeout] = 3600 is default<br>
  17239. number of seconds to wait before sensor <a href="#temperatureRefDev">temperatureRefDev</a> will be recognized n/a
  17240. </li>
  17241. <li><a name="EnOcean_pollInterval">pollInterval</a> t/s, [pollInterval] = 10 is default.<br>
  17242. [pollInterval] = 1 ... 1440.<br>
  17243. pollInterval is supported for roomCtrlPanel.00.
  17244. </li>
  17245. <li><a name="EnOcean_rampTime">rampTime</a> t/s or relative, [rampTime] = 1 is default.<br>
  17246. No ramping or for Eltako dimming speed set on the dimmer if [rampTime] = 0.<br>
  17247. Gateway/dimmung: Ramping time 1 s to 255 s or relative fast to low dimming speed if [rampTime] = 1 ... 255.<br>
  17248. lightCtrl.01: Ramping time 1 s to 65535 s<br>
  17249. rampTime is supported for gateway, command dimming and lightCtrl.01.
  17250. </li>
  17251. <li><a href="#readingFnAttributes">readingFnAttributes</a></li>
  17252. <li><a name="EnOcean_rcvRespAction">rcvRespAction</a> &lt;command&gt;<br>
  17253. Command being executed after an message from the aktor is received and before an response message is sent.
  17254. If &lt;command&gt; is enclosed in {}, then it is a perl expression, if it is enclosed in "", then it is a shell command,
  17255. 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
  17256. and the current readings $ACTUATORSTATE, $BATTERY, $COVER, $ENERGYINPUT, $ENERGYSTORAGE, $MAINTENANCEMODE, $OPERATIONMODE,
  17257. $ROOMTEMP, $SELFCTRL, $SETPOINT, $SETPOINTTEMP, $SUMMERMODE, $TEMPERATURE, $WINDOW for the subType hvac.01 and $NAME,
  17258. $BATTERY, $FEEDTEMP, $MAINTENANCEMODE, $OPERATIONMODE, $ROOMTEMP, $SETPOINT, $SETPOINTTEMP, $SUMMERMODE, $TEMPERATURE
  17259. for the subType hvac.04.
  17260. This data is available as a local variable in perl, as environment variable for shell
  17261. scripts, and will be textually replaced for Fhem commands.
  17262. </li>
  17263. <li><a name="EnOcean_remoteCode">remoteCode</a> &lt;00000000...FFFFFFFE&gt;<br>
  17264. Remote Management Security Code, 00000000 is interpreted as on code has been set.
  17265. </li>
  17266. <li><a name="EnOcean_remoteEEP">remoteEEP</a> &lt;00...FF&gt;-&lt;00...3F&gt;-&lt;00...7F&gt;<br>
  17267. Remote Management EnOcean Equipment Profile (EEP)
  17268. </li>
  17269. <li><a name="EnOcean_remoteID">remoteID</a> &lt;00000001...FFFFFFFE&gt;<br>
  17270. Remote Management Remote Device ID
  17271. </li>
  17272. <li><a name="EnOcean_remoteManagement">remoteManagement</a> client|manager|off,
  17273. [remoteManagement] = off is default.<br>
  17274. Enable Remote Management for the device.
  17275. </li>
  17276. <li><a name="EnOcean_remoteManufID">remoteManufID</a> &lt;000...7FF&gt;<br>
  17277. Remote Management Manufacturer ID
  17278. </li>
  17279. <li><a name="repeatingAllowed">repeatingAllowed</a> yes|no,
  17280. [repeatingAllowed] = yes is default.<br>
  17281. EnOcean Repeater in the transmission range of Fhem may forward data messages
  17282. of the device, if the attribute is set to yes.
  17283. </li>
  17284. <li><a name="EnOcean_releasedChannel">releasedChannel</a> A|B|C|D|I|0|auto, [releasedChannel] = auto is default.<br>
  17285. Attribute releasedChannel determines via which SenderID (subDefA ... subDef0) the command released is sent.
  17286. If [releasedChannel] = auto, the SenderID the last command A0, AI, B0, BI, C0, CI, D0 or DI is used.
  17287. Attribute releasedChannel is supported for attr switchType = central and attr switchType = channel.
  17288. </li>
  17289. <li><a name="EnOcean_reposition">reposition</a> directly|opens|closes, [reposition] = directly is default.<br>
  17290. Attribute reposition specifies how to adjust the internal positioning tracker before going to the new position.
  17291. </li>
  17292. <li><a name="EnOcean_rlcAlgo">rlcAlgo</a> 2++|3++<br>
  17293. RLC Algorithm
  17294. </li>
  17295. <li><a name="EnOcean_rlcRcv">rlcRcv</a> &lt;rolling code 2 or 3 byte hex&gt;<br>
  17296. Rolling Code for receive direction
  17297. </li>
  17298. <li><a name="EnOcean_rlcSnd">rlcSnd</a> &lt;rolling code 2 or 3 byte hex&gt;<br>
  17299. Rolling Code for send direction
  17300. </li>
  17301. <li><a name="EnOcean_rlcTX">rlcTX</a> false|true<br>
  17302. Rolling Code is expected in the received telegram
  17303. </li>
  17304. <li><a name="EnOcean_rltRepeat">rltRepeat</a> 16|32|64|128|256,
  17305. [rltRepeat] = 16 is default.<br>
  17306. Number of RLT MasterTest messages sent
  17307. </li>
  17308. <li><a name="EnOcean_rltType">rltType</a> 1BS|4BS,
  17309. [rltType] = 4BS is default.<br>
  17310. Type of RLT MasterTest message
  17311. </li>
  17312. <li><a name="scaleDecimals">scaleDecimals</a> 0 ... 9<br>
  17313. Decimal rounding with x digits of the scaled reading setpoint
  17314. </li>
  17315. <li><a name="EnOcean_teachMethod">teachMethod</a> 1BS|4B|confirm|GP|RPS|smartAck|STE|UTE<br>
  17316. teach-in method
  17317. </li>
  17318. <li><a name="scaleMax">scaleMax</a> &lt;floating-point number&gt;<br>
  17319. Scaled maximum value of the reading setpoint
  17320. </li>
  17321. <li><a name="scaleMin">scaleMin</a> &lt;floating-point number&gt;<br>
  17322. Scaled minimum value of the reading setpoint
  17323. </li>
  17324. <li><a name="EnOcean_secLevel">secLevel</a> encapsulation|encryption|off, [secLevel] = off is default<br>
  17325. Security level of the data
  17326. </li>
  17327. <li><a name="EnOcean_secMode">secMode</a> rcv|snd|bidir<br>
  17328. Telegram direction, which is secured
  17329. </li>
  17330. <li><a name="EnOcean_sendDevStatus">sendDevStatus</a> no|yes, [sendDevStatus] = no is default.<br>
  17331. Send new status of the device.
  17332. </li>
  17333. <li><a name="sensorMode">sensorMode</a> switch|pushbutton,
  17334. [sensorMode] = switch is default.<br>
  17335. The status "released" will be shown in the reading state if the
  17336. attribute is set to "pushbutton".
  17337. </li>
  17338. <li><a name="EnOcean_serviceOn">serviceOn</a> no|yes,
  17339. [serviceOn] = no is default.<br>
  17340. Device in Service Mode.
  17341. </li>
  17342. <li><a name="EnOcean_setCmdTrigger">setCmdTrigger</a> man|refDev, [setCmdTrigger] = man is default.<br>
  17343. Operation mode to send set commands<br>
  17344. If the attribute is set to "refDev", a device-specific set command is sent when the reference device is updated.
  17345. For the subType "roomSensorControl.05" and "fanCrtl.00" the reference "temperatureRefDev" is supported.<br>
  17346. For the subType "roomSensorControl.01" the references "humidityRefDev" and "temperatureRefDev" are supported.<br>
  17347. </li>
  17348. <li><a name="EnOcean_setpointRefDev">setpointRefDev</a> &lt;name&gt;<br>
  17349. Name of the device whose reference value is read. The reference values is
  17350. the reading setpoint.
  17351. </li>
  17352. <li><a name="EnOcean_setpointSummerMode">setpointSummerMode</a> valvePos/%,
  17353. [setpointSummerMode] = 0...100, 0 is default<br>
  17354. Valve position in summer operation
  17355. </li>
  17356. <li><a name="EnOcean_setpointTempRefDev">setpointTempRefDev</a> &lt;name&gt;<br>
  17357. Name of the device whose reference value is read. The reference values is
  17358. the reading setpointTemp.
  17359. </li>
  17360. <li><a name="EnOcean_settingAccuracy">settingAccuracy</a> high|low,
  17361. [settingAccuracy] = low is default.<br>
  17362. set setting accurancy.
  17363. </li>
  17364. <li><a href="#showtime">showtime</a></li>
  17365. <li><a name="shutTime">shutTime</a> &lt;channel1&gt;[:&lt;channel2&gt;[:&lt;channel3&gt;[:&lt;channel4&gt;]]]<br>
  17366. subType blindsCtrl.00, blindsCtrl.01: [shutTime] = 5 ... 300, 300 is default.<br>
  17367. subType manufProfile: [shutTime] = 1 ... 255, 255 is default.<br>
  17368. Use the attr shutTime to set the time delay to the position "Halt" in
  17369. seconds. Select a delay time that is at least as long as the shading element
  17370. or roller shutter needs to move from its end position to the other position.<br>
  17371. Notice subType blindsCrtl.00: The attribute can only be set while the actuator is online.
  17372. </li>
  17373. <li><a name="shutTimeCloses">shutTimeCloses</a> t/s, [shutTimeCloses] = 1 ... 255,
  17374. [shutTimeCloses] = [shutTime] is default.<br>
  17375. Set the attr shutTimeCloses to define the runtime used by the commands opens and closes.
  17376. Select a runtime that is at least as long as the value set by the delay switch of the actuator.
  17377. <br>
  17378. shutTimeCloses is supported for shutter.
  17379. </li>
  17380. <li><a name="subDef">subDef</a> &lt;EnOcean SenderID&gt;,
  17381. [subDef] = [DEF] is default.<br>
  17382. SenderID (<a href="#TCM">TCM</a> BaseID + offset) to control a bidirectional switch or actor.<br>
  17383. In order to control devices that send acknowledge telegrams, you cannot reuse the ID of this
  17384. devices, instead you have to create your own, which must be in the
  17385. allowed ID-Range of the underlying IO device. For this first query the
  17386. <a href="#TCM">TCM</a> with the "<code>get &lt;tcm&gt; idbase</code>" command. You can use
  17387. up to 128 IDs starting with the base shown there.<br>
  17388. If [subDef] = getNextID FHEM can assign a free SenderID alternatively. The system configuration
  17389. needs to be reloaded. The assigned SenderID will only displayed after the system configuration
  17390. has been reloaded, e.g. Fhem command rereadcfg.
  17391. </li>
  17392. <li><a name="subDefA">subDefA</a> &lt;EnOcean SenderID&gt;,
  17393. [subDefA] = [subDef] is default.<br>
  17394. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = A0|AI|released<br>
  17395. Used with switch type "channel". Set attr switchType to channel.<br>
  17396. subDefA is supported for switches.<br>
  17397. Second action is not sent.<br>
  17398. If [subDefA] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17399. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17400. </li>
  17401. <li><a name="subDefB">subDefB</a> &lt;EnOcean SenderID&gt;,
  17402. [subDefB] = [subDef] is default.<br>
  17403. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = B0|BI|released<br>
  17404. Used with switch type "channel". Set attr switchType to channel.<br>
  17405. subDefB is supported for switches.<br>
  17406. Second action is not sent.<br>
  17407. If [subDefB] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17408. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17409. </li>
  17410. <li><a name="subDefC">subDefC</a> &lt;EnOcean SenderID&gt;,
  17411. [subDefC] = [subDef] is default.<br>
  17412. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = C0|CI|released<br>
  17413. Used with switch type "channel". Set attr switchType to channel.<br>
  17414. subDefC is supported for switches.<br>
  17415. Second action is not sent.<br>
  17416. If [subDefC] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17417. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17418. </li>
  17419. <li><a name="subDefD">subDefD</a> &lt;EnOcean SenderID&gt;,
  17420. [subDefD] = [subDef] is default.<br>
  17421. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = D0|DI|released<br>
  17422. Used with switch type "channel". Set attr switchType to channel.<br>
  17423. subDefD is supported for switches.<br>
  17424. Second action is not sent.<br>
  17425. If [subDefD] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17426. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17427. </li>
  17428. <li><a name="subDef0">subDef0</a> &lt;EnOcean SenderID&gt;,
  17429. [subDef0] = [subDef] is default.<br>
  17430. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = A0|B0|C0|D0|released<br>
  17431. Used with switch type "central". Set attr switchType to central.<br>
  17432. Use the sensor type "zentral aus/ein" for Eltako devices.<br>
  17433. subDef0 is supported for switches.<br>
  17434. Second action is not sent.<br>
  17435. If [subDef0] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17436. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17437. </li>
  17438. <li><a name="subDefI">subDefI</a> &lt;EnOcean SenderID&gt;,
  17439. [subDefI] = [subDef] is default.<br>
  17440. SenderID (<a href="#TCM">TCM</a> BaseID + offset) for [value] = AI|BI|CI|DI<br>
  17441. Used with switch type "central". Set attr switchType to central.<br>
  17442. Use the sensor type "zentral aus/ein" for Eltako devices.<br>
  17443. subDefI is supported for switches.<br>
  17444. Second action is not sent.<br>
  17445. If [subDefI] = getNextID FHEM can assign a free SenderID alternatively. The assigned SenderID will only
  17446. displayed after the system configuration has been reloaded, e.g. Fhem command rereadcfg.
  17447. </li>
  17448. <li><a name="EnOcean_subDefH">subDefH</a> &lt;EnOcean SenderID&gt;,
  17449. [subDefH] = undef is default.<br>
  17450. SenderID (<a href="#TCM">TCM</a> BaseID + offset)<br>
  17451. Used with subType "multisensor.00". If the attribute subDefH is set, the position of the window handle as EEP F6-10-00
  17452. (windowHandle) telegram is forwarded.<br>
  17453. If [subDefH] = getNextID FHEM can assign a free SenderID alternatively.
  17454. </li>
  17455. <li><a name="EnOcean_subDefW">subDefW</a> &lt;EnOcean SenderID&gt;,
  17456. [subDefW] = undef is default.<br>
  17457. SenderID (<a href="#TCM">TCM</a> BaseID + offset)<br>
  17458. Used with subType "multisensor.00". If the attribute subDefW is set, the window state as EEP D5-00-01
  17459. (contact) telegram is forwarded.<br>
  17460. If [subDefW] = getNextID FHEM can assign a free SenderID alternatively.
  17461. </li>
  17462. <li><a href="#subType">subType</a></li>
  17463. <li><a name="subTypeSet">subTypeSet</a> &lt;type of device&gt;, [subTypeSet] = [subType] is default.<br>
  17464. Type of device (EEP Profile) used for sending commands. Set the Attribute manually.
  17465. The profile has to fit their basic profile. More information can be found in the basic profiles.
  17466. </li>
  17467. <li><a name="EnOcean_summerMode">summerMode</a> off|on,
  17468. [summerMode] = off is default.<br>
  17469. Put Battery Powered Actuator (hvac.01) or Heating Radiator Actuating Drive (hvac.04) in summer operation
  17470. to reduce energy consumption. If [summerMode] = on, the set commands are not executed.
  17471. </li>
  17472. <li><a name="EnOcean_switchHysteresis">switchHysteresis</a> &lt;value&gt;,
  17473. [switchHysteresis] = 1 is default.<br>
  17474. Switch Hysteresis
  17475. </li>
  17476. <li><a name="switchMode">switchMode</a> switch|pushbutton,
  17477. [switchMode] = switch is default.<br>
  17478. The set command "released" immediately after &lt;value&gt; is sent if the
  17479. attribute is set to "pushbutton".
  17480. </li>
  17481. <li><a name="switchType">switchType</a> direction|universal|central|channel,
  17482. [switchType] = direction is default.<br>
  17483. EnOcean Devices support different types of sensors, e. g. direction
  17484. switch, universal switch or pushbutton, central on/off.<br>
  17485. For Eltako devices these are the sensor types "Richtungstaster",
  17486. "Universalschalter" or "Universaltaster", "Zentral aus/ein".<br>
  17487. With the sensor type <code>direction</code> switch on/off commands are
  17488. accepted, e. g. B0, BI, released. Fhem can control an device with this
  17489. sensor type unique. This is the default function and should be
  17490. preferred.<br>
  17491. Some devices only support the <code>universal switch
  17492. </code> or <code>pushbutton</code>. With a Fhem command, for example,
  17493. B0 or BI is switched between two states. In this case Fhem cannot
  17494. control this device unique. But if the Attribute <code>switchType
  17495. </code> is set to <code>universal</code> Fhem synchronized with
  17496. a bidirectional device and normal on/off commands can be used.
  17497. If the bidirectional device response with the channel B
  17498. confirmation telegrams also B0 and BI commands are to be sent,
  17499. e g. channel A with A0 and AI. Also note that confirmation telegrams
  17500. needs to be sent.<br>
  17501. Partly for the switchType <code>central</code> two different SenderID
  17502. are required. In this case set the Attribute <code>switchType</code> to
  17503. <code>central</code> and define the Attributes
  17504. <a href="#subDef0">subDef0</a> and <a href="#subDefI">subDefI</a>.<br>
  17505. Furthermore, SenderIDs can be used depending on the channel A, B, C or D.
  17506. In this case set the Attribute switchType to <code>channel</code> and define
  17507. the Attributes <a href="#subDefA">subDefA</a>, <a href="#subDefB">subDefB</a>,
  17508. <a href="#subDefC">subDefC</a>, or <a href="#subDefD">subDefD</a>.
  17509. </li>
  17510. <li><a name="temperatureRefDev">temperatureRefDev</a> &lt;name&gt;<br>
  17511. Name of the device whose reference value is read. The reference values is
  17512. the reading temperature.
  17513. </li>
  17514. <li><a name="EnOcean_temperatureScale">temperatureScale</a> F|C|default|no_change, [temperatureScale] = no_change is default.<br>
  17515. temperatureScale is supported for roomCtrlPanel.00.
  17516. </li>
  17517. <li><a name="EnOcean_timeNotation">timeNotation</a> 12|24|default|no_change, [timeNotation] = no_change is default.<br>
  17518. timeNotation is supported for roomCtrlPanel.00.
  17519. </li>
  17520. <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>
  17521. [period] = FrMo|FrSu|ThFr|WeFr|TuTh|MoWe|SaSu|MoFr|MoSu|Su|Sa|Fr|Th|We|Tu|Mo<br>
  17522. [starttime] = [00..23]:[00|15|30|45]<br>
  17523. [endtime] = [00..23]:[00|15|30|45]<br>
  17524. [roomCtrlMode] = buildingProtection|comfort|economy|preComfort<br>
  17525. The Room Control Panel Kieback & Peter RBW322-FTL supports only [roomCtrlMode] = comfort.<br>
  17526. timeProgram is supported for roomCtrlPanel.00.
  17527. </li>
  17528. <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>
  17529. Transmission cycle of the tracker.
  17530. </li>
  17531. <li><a name="EnOcean_updateState">updateState</a> default|yes|no, [updateState] = default is default.<br>
  17532. update reading state after set commands
  17533. </li>
  17534. <li><a name="EnOcean_uteResponseRequest">uteResponseRequest</a> yes|no<br>
  17535. request UTE teach-in/teach-out response message, the standard value depends on the EEP profil
  17536. </li>
  17537. <li><a href="#verbose">verbose</a></li>
  17538. <li><a name="EnOcean_wakeUpCycle">wakeUpCycle</a> t/s, [wakeUpCycle] = 10 s ... 151200 s, 300 s is default.<br>
  17539. Transmission cycle of the actuator.
  17540. </li>
  17541. <li><a href="#webCmd">webCmd</a></li>
  17542. </ul>
  17543. </ul>
  17544. <br>
  17545. <a name="EnOceanevents"></a>
  17546. <b>Generated events</b>
  17547. <ul>
  17548. <ul>
  17549. <li><a name="EnOcean_remoteEvents">Remote Management</a><br>
  17550. <ul>
  17551. <li>remoteDevCfg&lt;0000...FFFF&gt;: &lt;device config&gt;</li>
  17552. <li>remoteFunction&lt;01...99&gt;: &lt;remote function number&gt;:&lt;remote manufacturer ID&gt;:&lt;explanation&gt;</li>
  17553. <li>remoteLastFunctionNumber: 001...FFF</li>
  17554. <li>remoteLastStatusReturnCode: 00...FF</li>
  17555. <li>remoteLearn: not_supported|supported</li>
  17556. <li>remoteLinkCfg&lt;in|out&gt;&lt;00...FF&gt;: &lt;data index&gt;:&lt;device config&gt;</li>
  17557. <li>remoteLinkTableDesc&lt;in|out&gt;&lt;00...FF&gt;: &lt;DeviceID&gt;:&lt;EEP&gt;:&lt;channel&gt;</li>
  17558. <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>
  17559. <li>remoteProductID: 00000000...FFFFFFFF</li>
  17560. <li>remoteRepeaterFilter: AND|OR</li>
  17561. <li>remoteRepeaterFunction: on|off|filter</li>
  17562. <li>remoteRepeaterLevel: 1|2</li>
  17563. <li>remoteTeach: not_supported|supported</li>
  17564. <li>remoteRSSI: LP/dBm</li>
  17565. <li>teach: &lt;result of teach procedure&gt;</li>
  17566. </ul>
  17567. </li>
  17568. <br><br>
  17569. <li>Switch (EEP F6-02-01 ... F6-03-02)<br>
  17570. <ul>
  17571. <li>A0</li>
  17572. <li>AI</li>
  17573. <li>B0</li>
  17574. <li>BI</li>
  17575. <li>C0</li>
  17576. <li>CI</li>
  17577. <li>D0</li>
  17578. <li>DI</li>
  17579. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17580. one of the above, e.g. A0 BI or D0 CI</li>
  17581. <li>buttons: pressed|released</li>
  17582. <li>state: &lt;BtnX&gt;[,&lt;BtnY&gt;]</li>
  17583. </ul><br>
  17584. Switches (remote controls) or actors with more than one
  17585. (pair) keys may have multiple channels e. g. B0/BI, A0/AI with one
  17586. SenderID or with separate addresses.
  17587. </li>
  17588. <br><br>
  17589. <li>Pushbutton Switch, Pushbutton Input Module (EEP F6-02-01 ... F6-02-02, F6-01-01)<br>
  17590. [Eltako FT55, FSM12, FSM61, FTS12]<br>
  17591. <ul>
  17592. <li>A0</li>
  17593. <li>AI</li>
  17594. <li>B0</li>
  17595. <li>BI</li>
  17596. <li>C0</li>
  17597. <li>CI</li>
  17598. <li>D0</li>
  17599. <li>DI</li>
  17600. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17601. one of the above, e.g. A0,BI or D0,CI</li>
  17602. <li>released</li>
  17603. <li>buttons: pressed|released</li>
  17604. <li>state: &lt;BtnX&gt;[,&lt;BtnY&gt;] [released]</li>
  17605. </ul><br>
  17606. The status of the device may become "released", this is not the case for a normal switch.<br>
  17607. Set attr model to FT55|FSM12|FSM61|FTS12 or attr sensorMode to pushbutton manually.
  17608. </li>
  17609. <br><br>
  17610. <li>Pushbutton Switch (EEP F6-3F-7F)<br>
  17611. [Eltako FGW14/FAM14 with internal decryption and RS-485 communication]<br>
  17612. <ul>
  17613. <li>A0</li>
  17614. <li>AI</li>
  17615. <li>B0</li>
  17616. <li>BI</li>
  17617. <li>C0</li>
  17618. <li>CI</li>
  17619. <li>D0</li>
  17620. <li>DI</li>
  17621. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17622. one of the above, e.g. A0,BI or D0,CI</li>
  17623. <li>released</li>
  17624. <li>buttons: pressed|released</li>
  17625. <li>state: &lt;BtnX&gt;[,&lt;BtnY&gt;] [released]</li>
  17626. </ul><br>
  17627. Set attr subType to switch.7F and manufID to 00D.<br>
  17628. The status of the device may become "released", this is not the case for
  17629. a normal switch. Set attr sensorMode to pushbutton manually.
  17630. </li>
  17631. <br><br>
  17632. <li>Pushbutton Switch (EEP D2-03-00)<br>
  17633. [EnOcean PTM 215 Modul]<br>
  17634. <ul>
  17635. <li>A0</li>
  17636. <li>AI</li>
  17637. <li>B0</li>
  17638. <li>BI</li>
  17639. <li>&lt;BtnX,BtnY&gt; First and second action where BtnX and BtnY is
  17640. one of the above, e.g. A0,BI</li>
  17641. <li>pressed</li>
  17642. <li>released</li>
  17643. <li>teach: &lt;result of teach procedure&gt;</li>
  17644. <li>energyBow: pressed|released</li>
  17645. <li>state: &lt;BtnX&gt;|&lt;BtnX&gt;,&lt;BtnY&gt;|released|pressed|teachIn|teachOut</li>
  17646. </ul><br>
  17647. The attr subType must be switch.00. This is done if the device was
  17648. created by autocreate. Set attr sensorMode to pushbutton manually if needed.
  17649. </li>
  17650. <br><br>
  17651. <li>Heating/Cooling Relay (EEP F6-02-01 ... F6-02-02)<br>
  17652. [Eltako FAE14, FHK14, untested]<br>
  17653. <ul>
  17654. <li>controllerMode: auto|off</li>
  17655. <li>energyHoldOff: normal|holdoff</li>
  17656. <li>buttons: pressed|released</li>
  17657. </ul><br>
  17658. Set attr subType to switch and model to FAE14|FHK14 manually. In addition
  17659. every telegram received from a teached-in temperature sensor (e.g. FTR55H)
  17660. is repeated as a confirmation telegram from the Heating/Cooling Relay
  17661. FAE14, FHK14. In this case set attr subType to e. g. roomSensorControl.05
  17662. and attr manufID to 00D.
  17663. </li>
  17664. <br><br>
  17665. <li>Key Card Activated Switch (EEP F6-04-01)<br>
  17666. [Eltako FKC, FKF, FZS, untested]<br>
  17667. <ul>
  17668. <li>keycard_inserted</li>
  17669. <li>keycard_removed</li>
  17670. <li>state: keycard_inserted|keycard_removed</li>
  17671. </ul><br>
  17672. Set attr subType to keycard manually.
  17673. </li>
  17674. <br><br>
  17675. <li>Wind Speed Threshold Detector (EEP F6-05-00)<br>
  17676. <ul>
  17677. <li>on</li>
  17678. <li>off</li>
  17679. <li>alarm: dead_sensor|off</li>
  17680. <li>windSpeed: dead_sensor|on|off</li>
  17681. <li>battery: low|ok</li>
  17682. <li>state: on|off</li>
  17683. </ul><br>
  17684. Set attr subType to windSpeed.00 manually.
  17685. </li>
  17686. <br><br>
  17687. <li>Liquid Leakage Sensor (EEP F6-05-01)<br>
  17688. [untested]<br>
  17689. <ul>
  17690. <li>dry</li>
  17691. <li>wet</li>
  17692. <li>state: dry|wet</li>
  17693. </ul><br>
  17694. Set attr subType to liquidLeakage manually.
  17695. </li>
  17696. <br><br>
  17697. <li>Smoke Detector (EEP F6-05-02)<br>
  17698. [Eltako FRW]<br>
  17699. <ul>
  17700. <li>smoke-alarm</li>
  17701. <li>off</li>
  17702. <li>alarm: dead_sensor|smoke-alarm|off</li>
  17703. <li>battery: low|ok</li>
  17704. <li>state: smoke-alarm|off</li>
  17705. </ul><br>
  17706. Set attr subType to smokeDetector.02 manually.
  17707. </li>
  17708. <br><br>
  17709. <li>Window Handle (EEP F6-10-00, D2-03-10)<br>
  17710. [HOPPE SecuSignal, Eltako FHF, Eltako FTKE]<br>
  17711. <ul>
  17712. <li>closed</li>
  17713. <li>open</li>
  17714. <li>tilted</li>
  17715. <li>open_from_tilted</li>
  17716. <li>state: closed|open|tilted|open_from_tilted</li>
  17717. </ul><br>
  17718. The device windowHandle or windowHandle.10 should be created by autocreate.
  17719. </li>
  17720. <br><br>
  17721. <li>Single Input Contact, Door/Window Contact<br>
  17722. 1BS Telegram (EEP D5-00-01)<br>
  17723. [EnOcean STM 320, STM 329, STM 250, Eltako FTK, Peha D 450 FU]
  17724. <ul>
  17725. <li>closed</li>
  17726. <li>open</li>
  17727. <li>teach: &lt;result of teach procedure&gt;</li>
  17728. <li>state: open|closed</li>
  17729. </ul></li>
  17730. The device should be created by autocreate.
  17731. <br><br>
  17732. <li>Temperature Sensors with with different ranges (EEP A5-02-01 ... A5-02-30)<br>
  17733. [EnOcean STM 330, Eltako FTF55, Thermokon SR65 ...]<br>
  17734. <ul>
  17735. <li>t/&#176C</li>
  17736. <li>temperature: t/&#176C (Sensor Range: t = &lt;t min&gt; &#176C ... &lt;t max&gt; &#176C)</li>
  17737. <li>state: t/&#176C</li>
  17738. </ul><br>
  17739. The attr subType must be tempSensor.01 ... tempSensor.30. This is done if the device was
  17740. created by autocreate.
  17741. </li>
  17742. <br><br>
  17743. <li>Temperatur and Humidity Sensor (EEP A5-04-02)<br>
  17744. [Eltako FAFT60, FIFT63AP]<br>
  17745. <ul>
  17746. <li>T: t/&#176C H: rH/% B: unknown|low|ok</li>
  17747. <li>battery: unknown|low|ok</li>
  17748. <li>energyStorage: unknown|empty|charged|full</li>
  17749. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  17750. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  17751. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 6.6 V)
  17752. <li>state: T: t/&#176C H: rH/% B: unknown|low|ok</li>
  17753. </ul><br>
  17754. The attr subType must be tempHumiSensor.02 and attr
  17755. manufID must be 00D for Eltako Devices. This is done if the device was
  17756. created by autocreate.
  17757. </li>
  17758. <br><br>
  17759. <li>Temperatur and Humidity Sensor (EEP A5-04-03)<br>
  17760. [untsted]<br>
  17761. <ul>
  17762. <li>T: t/&#176C H: rH/%</li>
  17763. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  17764. <li>telegramType: heartbeat|event</li>
  17765. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  17766. <li>state: T: t/&#176C H: rH/%</li>
  17767. </ul><br>
  17768. The attr subType must be tempHumiSensor.03. This is done if the device was
  17769. created by autocreate.
  17770. </li>
  17771. <br><br>
  17772. <li>Barometric Sensor (EEP A5-05-01)<br>
  17773. [untested]<br>
  17774. <ul>
  17775. <li>P/hPa</li>
  17776. <li>airPressure: P/hPa (Sensor Range: P = 500 hPa ... 1150 hPa</li>
  17777. <li>telegramType: heartbeat|event</li>
  17778. <li>state: P/hPa</li>
  17779. </ul><br>
  17780. The attr subType must be baroSensor.01. This is done if the device was
  17781. created by autocreate.
  17782. </li>
  17783. <br><br>
  17784. <li>Light Sensor (EEP A5-06-01)<br>
  17785. [Eltako FAH60, FAH63, FIH63, Thermokon SR65 LI]<br>
  17786. <ul>
  17787. <li>E/lx</li>
  17788. <li>brightness: E/lx (Sensor Range: 300 lx ... 30 klx, 600 lx ... 60 klx
  17789. , Sensor Range for Eltako: E = 0 lx ... 100 lx, 300 lx ... 30 klx)</li>
  17790. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 5.1 V)
  17791. <li>state: E/lx</li>
  17792. </ul><br>
  17793. Eltako devices only support Brightness.<br>
  17794. The attr subType must be lightSensor.01 and attr manufID must be 00D
  17795. for Eltako Devices. This is done if the device was created by
  17796. autocreate.
  17797. </li>
  17798. <br><br>
  17799. <li>Light Sensor (EEP A5-06-02)<br>
  17800. [untested]<br>
  17801. <ul>
  17802. <li>E/lx</li>
  17803. <li>brightness: E/lx (Sensor Range: 0 lx ... 1020 lx</li>
  17804. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.1 V)</li>
  17805. <li>state: E/lx</li>
  17806. </ul><br>
  17807. The attr subType must be lightSensor.02. This is done if the device was
  17808. created by autocreate.
  17809. </li>
  17810. <br><br>
  17811. <li>Light Sensor (EEP A5-06-03)<br>
  17812. [untested]<br>
  17813. <ul>
  17814. <li>E/lx</li>
  17815. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  17816. <li>errorCode: 251 ... 255</li>
  17817. <li>state: E/lx</li>
  17818. </ul><br>
  17819. The attr subType must be lightSensor.03. This is done if the device was
  17820. created by autocreate.
  17821. </li>
  17822. <br><br>
  17823. <li>Light Sensor (EEP A5-06-04)<br>
  17824. [untested]<br>
  17825. <ul>
  17826. <li>T: t/&#176C E: E/lx B: ok|low</li>
  17827. <li>battery: ok|low</li>
  17828. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 65535 lx)</li>
  17829. <li>energyStorage: 1/%</li>
  17830. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  17831. <li>state: T: t/&#176C E: E/lx B: ok|low</li>
  17832. </ul><br>
  17833. The attr subType must be lightSensor.04. This is done if the device was
  17834. created by autocreate.
  17835. </li>
  17836. <br><br>
  17837. <li>Light Sensor (EEP A5-06-05)<br>
  17838. [untested]<br>
  17839. <ul>
  17840. <li>E/lx</li>
  17841. <li>brightness: E/lx (Sensor Range: 0 lx ... 10200 lx</li>
  17842. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.1 V)</li>
  17843. <li>state: E/lx</li>
  17844. </ul><br>
  17845. The attr subType must be lightSensor.05. This is done if the device was created by autocreate.
  17846. </li>
  17847. <br><br>
  17848. <li>Occupancy Sensor (EEP A5-07-01, A5-07-02)<br>
  17849. [EnOcean EOSW]<br>
  17850. <ul>
  17851. <li>on|off</li>
  17852. <li>battery: ok|low</li>
  17853. <li>button: pressed|released</li>
  17854. <li>current: I/&#181;A (Sensor Range: I = 0 V ... 127.0 &#181;A)</li>
  17855. <li>errorCode: 251 ... 255</li>
  17856. <li>motion: on|off</li>
  17857. <li>sensorType: ceiling|wall</li>
  17858. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  17859. <li>state: on|off</li>
  17860. </ul><br>
  17861. The attr subType must be occupSensor.<01|02>. This is done if the device was
  17862. created by autocreate. Current is the solar panel current. Some values are
  17863. displayed only for certain types of devices.
  17864. </li>
  17865. <br><br>
  17866. <li>Eltako/PioTek-Tracker TF-TTB (EEP A5-07-01)<br>
  17867. <ul>
  17868. <li>on|off</li>
  17869. <li>battery: ok|low</li>
  17870. <li>button: pressed|released</li>
  17871. <li>motion: on|off</li>
  17872. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  17873. <li>state: on|off</li>
  17874. </ul><br>
  17875. The attr subType must be occupSensor.01. This is done if the device was
  17876. created by autocreate. The attr model has to be set manually to tracker.
  17877. Alternatively, the profile will be defined with inofficial EEP G5-07-01.<br>
  17878. The transmission cycle is set using the attribute <a href="#EnOcean_trackerWakeUpCycle">trackerWakeUpCycle</a>.
  17879. </li>
  17880. <br><br>
  17881. <li>Occupancy Sensor (EEP A5-07-03)<br>
  17882. [untested]<br>
  17883. <ul>
  17884. <li>M: on|off E: E/lx U: U/V</li>
  17885. <li>battery: ok|low</li>
  17886. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  17887. <li>errorCode: 251 ... 255</li>
  17888. <li>motion: on|off</li>
  17889. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  17890. <li>state: M: on|off E: E/lx U: U/V</li>
  17891. </ul><br>
  17892. The attr subType must be occupSensor.03. This is done if the device was
  17893. created by autocreate.
  17894. </li>
  17895. <br><br>
  17896. <li>Light, Temperatur and Occupancy Sensor (EEP A5-08-01 ... A5-08-03)<br>
  17897. [Eltako FABH63, FBH55, FBH63, FIBH63, Thermokon SR-MDS, PEHA 482 FU-BM DE]<br>
  17898. <ul>
  17899. <li>M: on|off E: E/lx P: absent|present T: t/&#176C U: U/V</li>
  17900. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 510, 1020, 1530 or 2048 lx)</li>
  17901. <li>motion: on|off</li>
  17902. <li>presence: absent|present</li>
  17903. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 51 &#176C or -30 &#176C ... 50 &#176C)</li>
  17904. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 5.1 V)
  17905. <li>state: M: on|off E: E/lx P: absent|present T: t/&#176C U: U/V</li>
  17906. </ul><br>
  17907. Eltako and PEHA devices only support Brightness and Motion.<br>
  17908. The attr subType must be lightTempOccupSensor.<01|02|03> and attr
  17909. manufID must be 00D for Eltako Devices. This is done if the device was
  17910. created by autocreate.
  17911. </li>
  17912. <br><br>
  17913. <li>Gas Sensor, CO Sensor (EEP A5-09-01)<br>
  17914. [untested]<br>
  17915. <ul>
  17916. <li>CO: c/ppm (Sensor Range: c = 0 ppm ... 255 ppm)</li>
  17917. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 255 &#176C)</li>
  17918. <li>state: c/ppm</li>
  17919. </ul><br>
  17920. The attr subType must be COSensor.01. This is done if the device was created by autocreate.
  17921. </li>
  17922. <br><br>
  17923. <li>Gas Sensor, CO Sensor (EEP A5-09-02)<br>
  17924. [untested]<br>
  17925. <ul>
  17926. <li>CO: c/ppm (Sensor Range: c = 0 ppm ... 1020 ppm)</li>
  17927. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 51.0 &#176C)</li>
  17928. <li>voltage: U/V</li> (Sensor Range: U = 0 V ... 5.1 V)
  17929. <li>state: c/ppm</li>
  17930. </ul><br>
  17931. The attr subType must be COSensor.02. This is done if the device was
  17932. created by autocreate.
  17933. </li>
  17934. <br><br>
  17935. <li>Gas Sensor, CO2 Sensor (EEP A5-09-04)<br>
  17936. [Thermokon SR04 CO2 *, Eltako FCOTF63, untested]<br>
  17937. <ul>
  17938. <li>airQuality: high|mean|moderate|low (Air Quality Classes DIN EN 13779)</li>
  17939. <li>CO2: c/ppm (Sensor Range: c = 0 ppm ... 2550 ppm)</li>
  17940. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  17941. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 51 &#176C)</li>
  17942. <li>state: T: t/&#176C H: rH/% CO2: c/ppm AQ: high|mean|moderate|low</li>
  17943. </ul><br>
  17944. The attr subType must be tempHumiCO2Sensor.01. This is done if the device was
  17945. created by autocreate.
  17946. </li>
  17947. <br><br>
  17948. <li>Gas Sensor, Volatile organic compounds (VOC) Sensor (EEP A5-09-05, A5-09-0C)<br>
  17949. [untested]<br>
  17950. <ul>
  17951. <li>concentration: c/[unit] (Sensor Range: c = 0 ... 655350</li>
  17952. <li>concentrationUnit: ppb|&mu;/m3</li>
  17953. <li>vocName: Name of last measured VOC</li>
  17954. <li>state: c/[unit]</li>
  17955. </ul><br>
  17956. The attr subType must be vocSensor.01. This is done if the device was
  17957. created by autocreate.
  17958. </li>
  17959. <br><br>
  17960. <li>Gas Sensor, Radon Sensor (EEP A5-09-06)<br>
  17961. [untested]<br>
  17962. <ul>
  17963. <li>Rn: A m3/Bq (Sensor Range: A = 0 Bq/m3 ... 1023 Bq/m3)</li>
  17964. <li>state: A m3/Bq</li>
  17965. </ul><br>
  17966. The attr subType must be radonSensor.01. This is done if the device was
  17967. created by autocreate.
  17968. </li>
  17969. <br><br>
  17970. <li>Gas Sensor, Particles Sensor (EEP A5-09-07)<br>
  17971. [untested]<br>
  17972. Three channels with particle sizes of up to 10 &mu;m, 2.5 &mu;m and 1 &mu;m are supported<br>.
  17973. <ul>
  17974. <li>particles_10: p m3/&mu;g | inactive (Sensor Range: p = 0 &mu;g/m3 ... 511 &mu;g/m3)</li>
  17975. <li>particles_2_5: p m3/&mu;g | inactive (Sensor Range: p = 0 &mu;g/m3 ... 511 &mu;g/m3)</li>
  17976. <li>particles_1: p m3/&mu;g | inactive (Sensor Range: p = 0 &mu;g/m3 ... 511 &mu;g/m3)</li>
  17977. <li>state: PM10: p m3/&mu;g PM2_5: p m3/&mu;g PM1: p m3/&mu;g</li>
  17978. </ul><br>
  17979. The attr subType must be particlesSensor.01. This is done if the device was
  17980. created by autocreate.
  17981. </li>
  17982. <br><br>
  17983. <li>CO2 Sensor (EEP A5-09-08, A5-09-09)<br>
  17984. [untested]<br>
  17985. <ul>
  17986. <li>CO2: c/ppm (Sensor Range: c = 0 ppm ... 2000 ppm)</li>
  17987. <li>powerFailureDetection: detected|not_detected</li>
  17988. <li>state: c/ppm</li>
  17989. </ul><br>
  17990. The attr subType must be CO2Sensor.01. This is done if the device was
  17991. created by autocreate.
  17992. </li>
  17993. <br><br>
  17994. <li>H Sensor (EEP A5-09-0A)<br>
  17995. [untested]<br>
  17996. <ul>
  17997. <li>c/ppm</li>
  17998. <li>voltage: U/V (Sensor Range: U = 2 V ... 5 V)</li>
  17999. <li>H: c/ppm (Sensor Range: c = 0 ppm ... 2000 ppm)</li>
  18000. <li>temperature: t/&#176C (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  18001. <li>state: c/ppm</li>
  18002. </ul><br>
  18003. The attr subType must be HSensor.01. This is done if the device was
  18004. created by autocreate.
  18005. </li>
  18006. <br><br>
  18007. <li>Radiation Sensor (EEP A5-09-0B)<br>
  18008. [untested]<br>
  18009. <ul>
  18010. <li>1/[unit]</li>
  18011. <li>radioactivity: 1/[unit] (Sensor Range: c = 0 [unit] ... 65535 [unit])</li>
  18012. <li>unit: uSv/h|cpm|Bq/L|Bq/kg</li>
  18013. <li>voltage: U/V (Sensor Range: U = 2 V ... 5 V)</li>
  18014. <li>state: 1/[unit]</li>
  18015. </ul><br>
  18016. The attr subType must be radiationSensor.01. This is done if the device was
  18017. created by autocreate.
  18018. </li>
  18019. <br><br>
  18020. <li>Room Sensor and Control Unit (EEP A5-10-01 ... A5-10-0D)<br>
  18021. [Eltako FTR55*, Thermokon SR04 *, Thanos SR *]<br>
  18022. <ul>
  18023. <li>T: t/&#176C SP: 0 ... 255 F: 0|1|2|3|auto SW: 0|1</li>
  18024. <li>fanStage: 0|1|2|3|auto</li>
  18025. <li>switch: on|off</li>
  18026. <li>setpoint: 0 ... 255</li>
  18027. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18028. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18029. <li>state: T: t/&#176C SP: 0 ... 255 F: 0|1|2|3|auto SW: on|off</li><br>
  18030. Alternatively for Eltako devices
  18031. <li>T: t/&#176C SPT: t/&#176C NR: t/&#176C</li>
  18032. <li>block: lock|unlock</li>
  18033. <li>nightReduction: t/K</li>
  18034. <li>setpointTemp: t/&#176C</li>
  18035. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18036. <li>state: T: t/&#176C SPT: t/&#176C NR: t/K</li><br>
  18037. </ul><br>
  18038. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18039. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18040. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18041. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18042. adjust the scaling alternatively.<br>
  18043. The attr subType must be roomSensorControl.05 and attr
  18044. manufID must be 00D for Eltako Devices. This is done if the device was
  18045. created by autocreate.
  18046. </li>
  18047. <br><br>
  18048. <li>Room Sensor and Control Unit (EEP A5-04-01, A5-10-10 ... A5-10-14)<br>
  18049. [Eltako FUTH65D, Thermokon SR04 * rH, Thanos SR *]<br>
  18050. <ul>
  18051. <li>T: t/&#176C H: rH/% SP: 0 ... 255 SW: 0|1</li>
  18052. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18053. <li>switch: 0|1</li>
  18054. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18055. <li>setpoint: 0 ... 255</li>
  18056. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18057. <li>state: T: t/&#176C H: rH/% SP: 0 ... 255 SW: 0|1</li>
  18058. </ul><br>
  18059. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18060. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18061. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18062. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18063. adjust the scaling alternatively.<br>
  18064. The attr subType must be roomSensorControl.01 and attr
  18065. manufID must be 00D for Eltako Devices. This is
  18066. done if the device was created by autocreate.
  18067. </li>
  18068. <br><br>
  18069. <li>Room Sensor and Control Unit (EEP A5-10-15 ... A5-10-17)<br>
  18070. [untested]<br>
  18071. <ul>
  18072. <li>T: t/&#176C SP: 0 ... 63 P: absent|present</li>
  18073. <li>presence: absent|present</li>
  18074. <li>temperature: t/&#176C (Sensor Range: t = -10 &#176C ... 41.2 &#176C)</li>
  18075. <li>setpoint: 0 ... 63</li>
  18076. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18077. <li>state: T: t/&#176C SP: 0 ... 63 P: absent|present</li>
  18078. </ul><br>
  18079. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18080. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18081. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18082. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18083. adjust the scaling alternatively.<br>
  18084. The attr subType must be roomSensorControl.02. This is done if the device was
  18085. created by autocreate.
  18086. </li>
  18087. <br><br>
  18088. <li>Room Sensor and Control Unit (EEP A5-10-18)<br>
  18089. [untested]<br>
  18090. <ul>
  18091. <li>T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18092. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18093. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18094. <li>presence: absent|present|disabled</li>
  18095. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18096. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18097. <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>
  18098. </ul><br>
  18099. The attr subType must be roomSensorControl.18. This is done if the device was
  18100. created by autocreate.
  18101. </li>
  18102. <br><br>
  18103. <li>Room Sensor and Control Unit (EEP A5-10-19)<br>
  18104. [untested]<br>
  18105. <ul>
  18106. <li>T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18107. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18108. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18109. <li>presence: absent|present|disabled</li>
  18110. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18111. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18112. <li>state: T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled</li>
  18113. </ul><br>
  18114. The attr subType must be roomSensorControl.19. This is done if the device was
  18115. created by autocreate.
  18116. </li>
  18117. <br><br>
  18118. <li>Room Sensor and Control Unit (EEP A5-10-1A)<br>
  18119. [untested]<br>
  18120. <ul>
  18121. <li>T: t/&#176C F: 0|1|2|3|4|5|auto|off SP: t/&#176C P: absent|present|disabled U: U/V</li>
  18122. <li>errorCode: 251 ... 255</li>
  18123. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18124. <li>presence: absent|present|disabled</li>
  18125. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18126. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18127. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18128. <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>
  18129. </ul><br>
  18130. The attr subType must be roomSensorControl.1A. This is done if the device was
  18131. created by autocreate.
  18132. </li>
  18133. <br><br>
  18134. <li>Room Sensor and Control Unit (EEP A5-10-1B)<br>
  18135. [untested]<br>
  18136. <ul>
  18137. <li>T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off P: absent|present|disabled U: U/V</li>
  18138. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18139. <li>errorCode: 251 ... 255</li>
  18140. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18141. <li>presence: absent|present|disabled</li>
  18142. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18143. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18144. <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>
  18145. </ul><br>
  18146. The attr subType must be roomSensorControl.1B. This is done if the device was
  18147. created by autocreate.
  18148. </li>
  18149. <br><br>
  18150. <li>Room Sensor and Control Unit (EEP A5-10-1C)<br>
  18151. [untested]<br>
  18152. <ul>
  18153. <li>T: t/&#176C B: E/lx F: 0|1|2|3|4|5|auto|off SP: E/lx P: absent|present|disabled</li>
  18154. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18155. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18156. <li>presence: absent|present|disabled</li>
  18157. <li>setpoint: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18158. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18159. <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>
  18160. </ul><br>
  18161. The attr subType must be roomSensorControl.1C. This is done if the device was
  18162. created by autocreate.
  18163. </li>
  18164. <br><br>
  18165. <li>Room Sensor and Control Unit (EEP A5-10-1D)<br>
  18166. [untested]<br>
  18167. <ul>
  18168. <li>T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: rH/% P: absent|present|disabled</li>
  18169. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18170. <li>fan: 0|1|2|3|4|5|auto|off</li>
  18171. <li>presence: absent|present|disabled</li>
  18172. <li>setpoint: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18173. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18174. <li>state: T: t/&#176C H: rH/% F: 0|1|2|3|4|5|auto|off SP: rH/% P: absent|present|disabled</li>
  18175. </ul><br>
  18176. The attr subType must be roomSensorControl.1D. This is done if the device was
  18177. created by autocreate.
  18178. </li>
  18179. <br><br>
  18180. <li>Room Sensor and Control Unit (EEP A5-10-1F)<br>
  18181. [untested]<br>
  18182. <ul>
  18183. <li>T: t/&#176C F: 0|1|2|3|auto SP: 0 ... 255 P: absent|present|disabled</li>
  18184. <li>fan: 0|1|2|3|auto</li>
  18185. <li>presence: absent|present|disabled</li>
  18186. <li>setpoint: 0 ... 255</li>
  18187. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18188. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18189. <li>state: T: t/&#176C F: 0|1|2|3|auto SP: 0 ... 255 P: absent|present|disabled</li>
  18190. </ul><br>
  18191. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18192. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18193. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18194. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18195. adjust the scaling alternatively.<br>
  18196. The attr subType must be roomSensorControl.1F. This is done if the device was
  18197. created by autocreate.
  18198. </li>
  18199. <br><br>
  18200. <li>Room Operation Panel (EEP A5-10-20, A5-10-21)<br>
  18201. [untested]<br>
  18202. <ul>
  18203. <li>T: t/&#176C H: rH/% SP: 0 ... 255 B: ok|low</li>
  18204. <li>activity: yes|no</li>
  18205. <li>battery: ok|low</li>
  18206. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18207. <li>setpoint: 0 ... 255</li>
  18208. <li>setpointMode: auto|frostProtect|setpoint</li>
  18209. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18210. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18211. <li>state: t/&#176C H: rH/% SP: 0 ... 255 B: ok|low</li>
  18212. </ul><br>
  18213. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18214. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18215. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18216. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18217. adjust the scaling alternatively.<br>
  18218. The attr subType must be roomSensorControl.20. This is done if the device was created by autocreate.
  18219. </li>
  18220. <br><br>
  18221. <li>Room Operation Panel (EEP A5-10-22, A5-10-23)<br>
  18222. [untested]<br>
  18223. <ul>
  18224. <li>T: t/&#176C H: rH/% SP: 0 ... 255 F: auto|off|1|2|3 O: occupied|unoccupied</li>
  18225. <li>fanSpeed: auto|off|1|2|3</li>
  18226. <li>humidity: rH/% (Sensor Range: rH = 0 % ... 100 %)</li>
  18227. <li>occupancy: occupied|unoccupied</li>
  18228. <li>setpoint: 0 ... 255</li>
  18229. <li>setpointScaled: &lt;floating-point number&gt;</li>
  18230. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18231. <li>state: t/&#176C H: rH/% SP: 0 ... 255 F: auto|off|1|2|3 O: occupied|unoccupied</li>
  18232. </ul><br>
  18233. The scaling of the setpoint adjustment is device- and vendor-specific. Set the
  18234. attributes <a href="#scaleMax">scaleMax</a>, <a href="#scaleMin">scaleMin</a> and
  18235. <a href="#scaleDecimals">scaleDecimals</a> for the additional scaled reading
  18236. setpointScaled. Use attribut <a href="#userReadings">userReadings</a> to
  18237. adjust the scaling alternatively.<br>
  18238. The attr subType must be roomSensorControl.22.
  18239. This is done if the device was created by autocreate.
  18240. </li>
  18241. <br><br>
  18242. <li>Lighting Controller State (EEP A5-11-01)<br>
  18243. [untested]<br>
  18244. <ul>
  18245. <li>on|off</li>
  18246. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 510 lx)</li>
  18247. <li>contact: open|closed</li>
  18248. <li>daylightHarvesting: enabled|disabled</li>
  18249. <li>dim: 0 ... 255</li>
  18250. <li>presence: absent|present</li>
  18251. <li>illum: 0 ... 255</li>
  18252. <li>mode: switching|dimming</li>
  18253. <li>powerRelayTimer: enabled|disabled</li>
  18254. <li>powerSwitch: on|off</li>
  18255. <li>repeater: enabled|disabled</li>
  18256. <li>state: on|off</li>
  18257. </ul><br>
  18258. The attr subType must be lightCtrlState.01 This is done if the device was
  18259. created by autocreate.
  18260. </li>
  18261. <br><br>
  18262. <li>Temperature Controller Output (EEP A5-11-02)<br>
  18263. [untested]<br>
  18264. <ul>
  18265. <li>t/&#176C</li>
  18266. <li>alarm: on|off</li>
  18267. <li>controlVar: cvar (Sensor Range: cvar = 0 % ... 100 %)</li>
  18268. <li>controllerMode: auto|heating|cooling|off</li>
  18269. <li>controllerState: auto|override</li>
  18270. <li>energyHoldOff: normal|holdoff</li>
  18271. <li>fan: 0 ... 3|auto</li>
  18272. <li>presence: present|absent|standby|frost</li>
  18273. <li>setpointTemp: t/&#176C (Sensor Range: t = 0 &#176C ... 51.2 &#176C)</li>
  18274. <li>state: t/&#176C</li>
  18275. </ul><br>
  18276. The attr subType must be tempCtrlState.01 This is done if the device was
  18277. created by autocreate.
  18278. </li>
  18279. <br><br>
  18280. <li><a name="Blind Status">Blind Status</a> (EEP A5-11-03)<br>
  18281. [untested, experimental status]<br>
  18282. <ul>
  18283. <li>open|closed|not_reached|not_available</li>
  18284. <li>alarm: on|off|no endpoints defined|not used</li>
  18285. <li>anglePos: &alpha;/&#176 (Sensor Range: &alpha; = -180 &#176 ... 180 &#176)</li>
  18286. <li>endPosition: open|closed|not_reached|not_available</li>
  18287. <li>position: pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  18288. <li>positionMode: normal|inverse</li>
  18289. <li>serviceOn: yes|no</li>
  18290. <li>shutterState: opens|closes|stopped|not_available</li>
  18291. <li>state: open|closed|not_reached|not_available</li>
  18292. </ul><br>
  18293. The attr subType must be shutterCtrlState.01 This is done if the device was
  18294. created by autocreate.<br>
  18295. The profile is linked with <a href="#Blind Command Central">Blind Command Central</a>.
  18296. The profile <a href="#Blind Command Central">Blind Command Central</a>
  18297. controls the devices centrally. For that the attributes subDef, subTypeSet
  18298. and gwCmd have to be set manually.
  18299. </li>
  18300. <br><br>
  18301. <li>Extended Lighting Status (EEP A5-11-04)<br>
  18302. [untested]<br>
  18303. <ul>
  18304. <li>on|off</li>
  18305. <li>alarm: off|lamp_failure|internal_failure|external_periphery_failure</li>
  18306. <li>blue: 0 ... 255</li>
  18307. <li>current: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18308. <li>currentUnit: mA|A</li>
  18309. <li>dim: 0 ... 255</li>
  18310. <li>energy: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18311. <li>energyUnit: Wh|kWh|MWh|GWh</li>
  18312. <li>green: 0 ... 255</li>
  18313. <li>measuredValue: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18314. <li>measureUnit: unknown</li>
  18315. <li>lampOpHours: t/h |unknown (Sensor range: t = 0 h ... 65535 h)</li>
  18316. <li>power: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18317. <li>powerSwitch: on|off</li>
  18318. <li>powerUnit: mW|W|kW|MW</li>
  18319. <li>red: 0 ... 255</li>
  18320. <li>rgb: RRGGBB (red (R), green (G) or blue (B) color component values: 00 ... FF)</li>
  18321. <li>serviceOn: yes|no</li>
  18322. <li>voltage: &lt;formula symbol&gt;/&lt;unit&gt; (Sensor range: &lt;formula symbol&gt; = 0 ... 65535 &lt;unit&gt;</li>
  18323. <li>voltageUnit: mV|V</li>
  18324. <li>state: on|off</li>
  18325. </ul><br>
  18326. The attr subType must be lightCtrlState.02 This is done if the device was
  18327. created by autocreate.
  18328. </li>
  18329. <br><br>
  18330. <li>Dual Channel Switch Actuator (EEP A5-11-05)<br>
  18331. [untested]<br>
  18332. <ul>
  18333. <li>1: on|off 2: on|off</li>
  18334. <li>channel1: on|off</li>
  18335. <li>channel2: on|off</li>
  18336. <li>workingMode: 1 ... 4</li>
  18337. <li>state: 1: on|off 2: on|off</li>
  18338. </ul><br>
  18339. The attr subType must be switch.05. This is done if the device was created by autocreate.
  18340. </li>
  18341. <br><br>
  18342. <li>Automated meter reading (AMR), Counter (EEP A5-12-00)<br>
  18343. [Thermokon SR-MI-HS, untested]<br>
  18344. <ul>
  18345. <li>1/s</li>
  18346. <li>currentValue<00 ... 15>: 1/s</li>
  18347. <li>counter<00 ... 15>: 0 ... 16777215</li>
  18348. <li>state: 1/s</li>
  18349. </ul><br>
  18350. The attr subType must be autoMeterReading.00. This is done if the device was
  18351. created by autocreate.
  18352. </li>
  18353. <br><br>
  18354. <li>Automated meter reading (AMR), Electricity (EEP A5-12-01)<br>
  18355. [Eltako FSS12, DSZ14DRS, DSZ14WDRS, Thermokon SR-MI-HS, untested]<br>
  18356. [Eltako FWZ12-16A tested]<br>
  18357. <ul>
  18358. <li>P/W</li>
  18359. <li>power: P/W</li>
  18360. <li>energy<0 ... 15>: E/kWh</li>
  18361. <li>currentTariff: 0 ... 15</li>
  18362. <li>serialNumber: S-&lt;nnnnnn&gt;</li>
  18363. <li>state: P/W</li>
  18364. </ul><br>
  18365. The attr subType must be autoMeterReading.01 and attr
  18366. manufID must be 00D for Eltako Devices. This is done if the device was
  18367. created by autocreate.
  18368. </li>
  18369. <br><br>
  18370. <li>Automated meter reading (AMR), Gas, Water (EEP A5-12-02, A5-12-03)<br>
  18371. [untested]<br>
  18372. <ul>
  18373. <li>Vs/l</li>
  18374. <li>flowrate: Vs/l</li>
  18375. <li>consumption<0 ... 15>: V/m3</li>
  18376. <li>currentTariff: 0 ... 15</li>
  18377. <li>state: Vs/l</li>
  18378. </ul><br>
  18379. The attr subType must be autoMeterReading.02|autoMeterReading.03.
  18380. This is done if the device was created by autocreate.
  18381. </li>
  18382. <br><br>
  18383. <li>Automated meter reading (AMR), Temperatur, Load (EEP A5-12-04)<br>
  18384. [untested]<br>
  18385. <ul>
  18386. <li>T: t/&#176C W: m/g B: full|ok|low|empty</li>
  18387. <li>battery: full|ok|low|empty</li>
  18388. <li>temperature: t/&#176C (Sensor Range: t = -40 &#176C ... 40 &#176C)</li>
  18389. <li>weight: m/g</li>
  18390. <li>state: T: t/&#176C W: m/g B: full|ok|low|empty</li>
  18391. </ul><br>
  18392. The attr subType must be autoMeterReading.04.
  18393. This is done if the device was created by autocreate.
  18394. </li>
  18395. <br><br>
  18396. <li>Automated meter reading (AMR), Temperatur, Container Sensor (EEP A5-12-05)<br>
  18397. [untested]<br>
  18398. <ul>
  18399. <li>T: t/&#176C L: <location0 ... location9> B: full|ok|low|empty</li>
  18400. <li>amount: 0 ... 10</li>
  18401. <li>battery: full|ok|low|empty</li>
  18402. <li>location<0 ... 9>: possessed|not_possessed</li>
  18403. <li>temperature: t/&#176C (Sensor Range: t = -40 &#176C ... 40 &#176C)</li>
  18404. <li>state: T: t/&#176C L: <location0 ... location9> B: full|ok|low|empty</li>
  18405. </ul><br>
  18406. The attr subType must be autoMeterReading.05.
  18407. This is done if the device was created by autocreate.
  18408. </li>
  18409. <br><br>
  18410. <li>Automated meter reading (AMR), Current Meter 16 Channels (EEP A5-12-10)<br>
  18411. [untested]<br>
  18412. <ul>
  18413. <li>I/mA</li>
  18414. <li>current<00 ... 15>: I/mA (Sensor Range: I = 0 mA ... 16777215 mA)</li>
  18415. <li>electricChange<00 ... 15>: Q/Ah (Sensor Range: Q = 0 Ah ... 16777215 Ah)</li>
  18416. <li>currentTariff: 00 ... 15</li>
  18417. <li>state: I/mA</li>
  18418. </ul><br>
  18419. The attr subType must be autoMeterReading.10. This is done if the device was created by autocreate.
  18420. </li>
  18421. <br><br>
  18422. <li>Environmental Applications<br>
  18423. Weather Station (EEP A5-13-01)<br>
  18424. Sun Intensity (EEP A5-13-02)<br>
  18425. [Eltako FWS61]<br>
  18426. <ul>
  18427. <li>T: t/&#176C B: E/lx W: Vs/m IR: yes|no</li>
  18428. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 999 lx)</li>
  18429. <li>dayNight: day|night</li>
  18430. <li>hemisphere: north|south</li>
  18431. <li>isRaining: yes|no</li>
  18432. <li>sunEast: E/lx (Sensor Range: E = 1 lx ... 150 klx)</li>
  18433. <li>sunSouth: E/lx (Sensor Range: E = 1 lx ... 150 klx)</li>
  18434. <li>sunWest: E/lx (Sensor Range: E = 1 lx ... 150 klx)</li>
  18435. <li>temperature: t/&#176C (Sensor Range: t = -40 &#176C ... 80 &#176C)</li>
  18436. <li>windSpeed: Vs/m (Sensor Range: V = 0 m/s ... 70 m/s)</li>
  18437. <li>state:T: t/&#176C B: E/lx W: Vs/m IR: yes|no</li>
  18438. </ul><br>
  18439. Brightness is the strength of the dawn light. SunEast,
  18440. sunSouth and sunWest are the solar radiation from the respective
  18441. compass direction. IsRaining is the rain indicator.<br>
  18442. The attr subType must be environmentApp and attr manufID must be 00D
  18443. for Eltako Devices. This is done if the device was created by
  18444. autocreate.<br>
  18445. The Eltako Weather Station FWS61 supports not the day/night indicator
  18446. (dayNight).<br>
  18447. </li>
  18448. <br><br>
  18449. <li>Environmental Applications<br>
  18450. Data Exchange (EEP A5-13-03)<br>
  18451. Time and Day Exchange (EEP A5-13-04)<br>
  18452. Direction Exchange (EEP A5-13-05)<br>
  18453. Geographic Exchange (EEP A5-13-06)<br>
  18454. <ul>
  18455. <li>azimuth: &alpha;/&deg; (Sensor Range: &alpha; = 0 &deg; ... 359 &deg;)</li>
  18456. <li>date: JJJJ-MM-DD</li>
  18457. <li>elevation: &beta;/&deg; (Sensor Range: &beta; = -90 &deg; ... 90 &deg;)</li>
  18458. <li>latitude: &phi;/&deg; (Sensor Range: &phi; = -90 &deg; ... 90 &deg;)</li>
  18459. <li>longitude: &lambda;/&deg; (Sensor Range: &lambda; = -180 &deg; ... 180 &deg;)</li>
  18460. <li>time: hh:mm:ss [AM|PM]</li>
  18461. <li>timeSource: GPS|RTC</li>
  18462. <li>weekday: Monday|Tuesday|Wednesday|Thursday|Friday|Saturday|Sunday</li>
  18463. </ul><br>
  18464. The attr subType must be environmentApp. This is done if the device was created by
  18465. autocreate.
  18466. </li>
  18467. <br><br>
  18468. <li>Environmental Applications<br>
  18469. Sun Position and Radiation (EEP A5-13-10)<br>
  18470. [untested]<br>
  18471. <ul>
  18472. <li>SRA: E m2/W SNA: &alpha;/&deg; SNE: &beta;/&deg;</li>
  18473. <li>dayNight: day|night</li>
  18474. <li>solarRadiation: E m2/W (Sensor Range: E = 0 W/m2 ... 2000 W/m2)</li>
  18475. <li>sunAzimuth: &alpha;/&deg; (Sensor Range: &alpha; = -90 &deg; ... 90 &deg;)</li>
  18476. <li>sunElevation: &beta;/&deg; (Sensor Range: &beta; = 0 &deg; ... 90 &deg;)</li>
  18477. <li>state:SRA: E m2/W SNA: &alpha;/&deg; SNE: &beta;/&deg;</li>
  18478. </ul><br>
  18479. The attr subType must be environmentApp. This is done if the device was created by
  18480. autocreate.
  18481. </li>
  18482. <br><br>
  18483. <li>Wind Sensor (EEP A5-13-07)<br>
  18484. [Hideki, untested]<br>
  18485. <ul>
  18486. <li>Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18487. <li>battery: ok|low</li>
  18488. <li>windSpeedAverage: Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18489. <li>windSpeedDirection: NNE|NE|ENE|E|ESE|SE|SSE|S|SSW|SW|WSW|W|WNW|NW|NNW|N</li>
  18490. <li>windSpeedMax: Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18491. <li>state:Vh/km (Sensor Range: V = 0 km/h ... 199.9 km/h)</li>
  18492. </ul><br>
  18493. The attr subType must be windSensor.01. This is done if the device was created by
  18494. autocreate.<br>
  18495. </li>
  18496. <br><br>
  18497. <li>Rain Sensor (EEP A5-13-08)<br>
  18498. [Hideki, untested]<br>
  18499. <ul>
  18500. <li>H/mm</li>
  18501. <li>battery: ok|low</li>
  18502. <li>rain: H/mm</li>
  18503. <li>state:H/mm</li>
  18504. </ul><br>
  18505. The amount of rainfall is calculated at intervals of 183 s.<br>
  18506. The attr subType must be rainSensor.01. This is done if the device was created by
  18507. autocreate.<br>
  18508. </li>
  18509. <br><br>
  18510. <li>Multi-Func Sensor (EEP A5-14-01 ... A5-14-06)<br>
  18511. [untested]<br>
  18512. <ul>
  18513. <li>C: open|closed V: on|off E: E/lx U: U/V</li>
  18514. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx, over range)</li>
  18515. <li>contact: open|closed</li>
  18516. <li>errorCode: 251 ... 255</li>
  18517. <li>vibration: on|off</li>
  18518. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18519. <li>state: C: open|closed V: on|off E: E/lx U: U/V</li>
  18520. </ul><br>
  18521. The attr subType must be multiFuncSensor. This is done if the device was
  18522. created by autocreate.
  18523. </li>
  18524. <br><br>
  18525. <li>Dual Door Contact (EEP A5-14-07, A5-14-08)<br>
  18526. [untested]<br>
  18527. <ul>
  18528. <li>C: open|closed B: unlocked|locked V: on|off U: U/V</li>
  18529. <li>alarm: dead_sensor</li>
  18530. <li>block: unlocked|locked</li>
  18531. <li>contact: open|closed</li>
  18532. <li>vibration: on|off</li>
  18533. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18534. <li>state: C: open|closed B: unlocked|locked V: on|off U: U/V</li>
  18535. </ul><br>
  18536. The attr subType must be doorContact. This is done if the device was
  18537. created by autocreate.
  18538. </li>
  18539. <br><br>
  18540. <li>Window/Door Contact (EEP A5-14-09, A5-14-0A)<br>
  18541. [untested]<br>
  18542. <ul>
  18543. <li>W: open|tilt|closed B: unlocked|locked V: on|off U: U/V</li>
  18544. <li>alarm: dead_sensor</li>
  18545. <li>vibration: on|off</li>
  18546. <li>voltage: U/V (Sensor Range: U = 0 V ... 5.0 V)</li>
  18547. <li>window: open|tilt|closed</li>
  18548. <li>state: W: open|tilt|closed V: on|off U: U/V</li>
  18549. </ul><br>
  18550. The attr subType must be windowContact. This is done if the device was
  18551. created by autocreate.
  18552. </li>
  18553. <br><br>
  18554. <li>Battery Powered Actuator (EEP A5-20-01)<br>
  18555. [Kieback&Peter MD15-FTL-xx]<br>
  18556. <ul>
  18557. <li>T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18558. <li>actuatorState: obstructed|ok</li>
  18559. <li>alarm: no_response_from_actuator</li>
  18560. <li>battery: ok|low</li>
  18561. <li>cover: open|closed</li>
  18562. <li>delta: &lt;floating-point number&gt;</li>
  18563. <li>energyInput: enabled|disabled</li>
  18564. <li>energyStorage: charged|empty</li>
  18565. <li>maintenanceMode: off|runInit|valveClosed|valveOpend:runInit</li>
  18566. <li>operationMode: off|setpoint|setpointTemp</li>
  18567. <li>p_d: &lt;floating-point number&gt;</li>
  18568. <li>p_i: &lt;floating-point number&gt;</li>
  18569. <li>p_p: &lt;floating-point number&gt;</li>
  18570. <li>pidAlarm: actuator_in_errorPos|dead_sensor|no_temperature_value|setpoint_device_missing</li>
  18571. <li>pidState: alarm|idle|processing|start|stop|</li>
  18572. <li>roomTemp: t/&#176C</li>
  18573. <li>selfCtl: on|off</li>
  18574. <li>setpoint: setpoint/%</li>
  18575. <li>setpointSet: setpoint/%</li>
  18576. <li>setpointCalc: setpoint/%</li>
  18577. <li>setpointTemp: t/&#176C</li>
  18578. <li>setpointTempSet: t/&#176C</li>
  18579. <li>teach: &lt;result of teach procedure&gt;</li>
  18580. <li>temperature: t/&#176C</li>
  18581. <li>waitingCmds: no_change|runInit|setpoint|setpointTemp|valveCloses|valveOpens</li>
  18582. <li>wakeUpCycle: t/s</li>
  18583. <li>window: open|closed</li>
  18584. <li>state: T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18585. </ul><br>
  18586. The internal temperature sensor (roomTemp) of the Micropelt iTRV is not suitable as
  18587. a room thermostat.<br>
  18588. The attr subType must be hvac.01. This is done if the device was created by
  18589. autocreate.
  18590. </li>
  18591. <br><br>
  18592. <li>Heating Radiator Actuating Drive (EEP A5-20-04)<br>
  18593. [Holter SmartDrive MX]<br>
  18594. <ul>
  18595. <li>T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18596. <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>
  18597. <li>battery: ok|empty</li>
  18598. <li>blockKey: yes|no</li>
  18599. <li>delta: &lt;floating-point number&gt;</li>
  18600. <li>feedTemp: t/&#176C</li>
  18601. <li>maintenanceMode: off|runInit|valveClosed|valveOpend:runInit</li>
  18602. <li>measurementState: active|inactive</li>
  18603. <li>operationMode: off|setpoint|setpointTemp</li>
  18604. <li>p_d: &lt;floating-point number&gt;</li>
  18605. <li>p_i: &lt;floating-point number&gt;</li>
  18606. <li>p_p: &lt;floating-point number&gt;</li>
  18607. <li>pidAlarm: actuator_in_errorPos|dead_sensor|no_temperature_value|setpoint_device_missing</li>
  18608. <li>pidState: alarm|idle|processing|start|stop|</li>
  18609. <li>roomTemp: t/&#176C</li>
  18610. <li>setpoint: setpoint/%</li>
  18611. <li>setpointSet: setpoint/%</li>
  18612. <li>setpointCalc: setpoint/%</li>
  18613. <li>setpointTemp: t/&#176C</li>
  18614. <li>setpointTempSet: t/&#176C</li>
  18615. <li>teach: &lt;result of teach procedure&gt;</li>
  18616. <li>temperature: t/&#176C</li>
  18617. <li>waitingCmds: no_change|runInit|setpoint|setpointTemp|valveCloses|valveOpens</li>
  18618. <li>state: T: t/&#176C SPT: t/&#176C SP: setpoint/%</li>
  18619. </ul><br>
  18620. The attr subType must be hvac.04. This is done if the device was created by
  18621. autocreate.
  18622. </li>
  18623. <br><br>
  18624. <li>Generic HVAC Interface (EEP A5-20-10)<br>
  18625. [IntesisBox PA-AC-ENO-1i]<br>
  18626. <ul>
  18627. <li>on|off</li>
  18628. <li>ctrl: auto|0...100</li>
  18629. <li>fanSpeed: auto|1...14</li>
  18630. <li>occupancy: occupied|off|standby|unoccupied</li>
  18631. <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>
  18632. <li>vanePosition: auto|horizontal|position_2|position_3|position_4|vertical|swing|vertical_swing|horizontal_swing|hor_vert_swing|stop_swing</li>
  18633. <li>powerSwitch: on|off</li>
  18634. <li>teach: &lt;result of teach procedure&gt;</li>
  18635. <li>state: on|off</li>
  18636. </ul><br>
  18637. The attr subType must be hvac.10. This is done if the device was created by
  18638. autocreate.
  18639. </li>
  18640. <br><br>
  18641. <li>Generic HVAC Interface - Error Control (EEP A5-20-11)<br>
  18642. [IntesisBox PA-AC-ENO-1i]<br>
  18643. <ul>
  18644. <li>error|ok</li>
  18645. <li>alarm: error|ok</li>
  18646. <li>errorCode: 0...65535</li>
  18647. <li>externalDisable: disable|enable</li>
  18648. <li>keyCardDisable: disable|enable</li>
  18649. <li>otherDisable: disable|enable</li>
  18650. <li>powerSwitch: on|off</li>
  18651. <li>remoteCtrl: disable|enable</li>
  18652. <li>teach: &lt;result of teach procedure&gt;</li>
  18653. <li>window: closed|opened</li>
  18654. <li>windowDisable: disable|enable</li>
  18655. <li>state: error|ok</li>
  18656. </ul><br>
  18657. The attr subType must be hvac.11. This is done if the device was created by
  18658. autocreate.
  18659. </li>
  18660. <br><br>
  18661. <li>Digital Input (EEP A5-30-01, A5-30-02)<br>
  18662. [Thermokon SR65 DI, untested]<br>
  18663. <ul>
  18664. <li>open|closed</li>
  18665. <li>battery: ok|low (only EEP A5-30-01)</li>
  18666. <li>contact: open|closed</li>
  18667. <li>teach: &lt;result of teach procedure&gt;</li>
  18668. <li>state: open|closed</li>
  18669. </ul><br>
  18670. The attr subType must be digitalInput.01 or digitalInput.02. This is done if the device was
  18671. created by autocreate.
  18672. </li>
  18673. <br><br>
  18674. <li>Digital Input (EEP A5-30-03)<br>
  18675. 4 digital Inputs, Wake, Temperature [untested]<br>
  18676. <ul>
  18677. <li>T: t/&#176C I: 0|1 0|1 0|1 0|1 W: 0|1</li>
  18678. <li>in0: 0|1</li>
  18679. <li>in1: 0|1</li>
  18680. <li>in2: 0|1</li>
  18681. <li>in3: 0|1</li>
  18682. <li>teach: &lt;result of teach procedure&gt;</li>
  18683. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  18684. <li>wake: high|low</li>
  18685. <li>state: T: t/&#176C I: 0|1 0|1 0|1 0|1 W: high|low</li>
  18686. </ul><br>
  18687. The attr subType must be digitalInput.03. This is done if the device was
  18688. created by autocreate.
  18689. </li>
  18690. <br><br>
  18691. <li>Digital Input (EEP A5-30-04)<br>
  18692. 3 digital Inputs, 1 digital Input 8 bits [untested]<br>
  18693. <ul>
  18694. <li>0|1 0|1 0|1 0...255</li>
  18695. <li>in0: 0|1</li>
  18696. <li>in1: 0|1</li>
  18697. <li>in2: 0|1</li>
  18698. <li>in3: 0...255</li>
  18699. <li>teach: &lt;result of teach procedure&gt;</li>
  18700. <li>state: 0|1 0|1 0|1 0...255</li>
  18701. </ul><br>
  18702. The attr subType must be digitalInput.04. This is done if the device was
  18703. created by autocreate.
  18704. </li>
  18705. <br><br>
  18706. <li>Digital Input, single input contact, retransmission, battery monitor (EEP A5-30-05)<br>
  18707. [untested]<br>
  18708. <ul>
  18709. <li>error|event|heartbeat</li>
  18710. <li>battery: U/V (Range: U = 0 V ... 3.3 V</li>
  18711. <li>signalIdx: 0 ... 127</li>
  18712. <li>teach: &lt;result of teach procedure&gt;</li>
  18713. <li>telegramType: event|heartbeat</li>
  18714. <li>state: error|event|heartbeat</li>
  18715. </ul><br>
  18716. The attr subType must be digitalInput.05. This is done if the device was
  18717. created by autocreate.
  18718. </li>
  18719. <li>Energy management, demand response (EEP A5-37-01)<br>
  18720. <br>
  18721. <ul>
  18722. <li>on|off|waiting_for_start|waiting_for_stop</li>
  18723. <li>level: 0...15</li>
  18724. <li>powerUsage: powerUsage/%</li>
  18725. <li>powerUsageLevel: max|min</li>
  18726. <li>powerUsageScale: rel|max</li>
  18727. <li>randomEnd: yes|no</li>
  18728. <li>randomStart: yes|no</li>
  18729. <li>setpoint: 0...255</li>
  18730. <li>teach: &lt;result of teach procedure&gt;</li>
  18731. <li>timeout: yyyy-mm-dd hh:mm:ss</li>
  18732. <li>state: on|off|waiting_for_start|waiting_for_stop</li>
  18733. </ul><br>
  18734. The attr subType must be energyManagement.01. This is done if the device was
  18735. created by autocreate.
  18736. </li>
  18737. <br><br>
  18738. <li>Gateway (EEP A5-38-08)<br>
  18739. Switching<br>
  18740. [Eltako FLC61, FSA12, FSR14]<br>
  18741. <ul>
  18742. <li>on</li>
  18743. <li>off</li>
  18744. <li>executeTime: t/s (Sensor Range: t = 0.1 s ... 6553.5 s or 0 if no time specified)</li>
  18745. <li>executeType: duration|delay</li>
  18746. <li>block: lock|unlock</li>
  18747. <li>teach: &lt;result of teach procedure&gt;</li>
  18748. <li>state: on|off</li>
  18749. </ul><br>
  18750. The attr subType must be gateway and gwCmd must be switching. This is done if the device was
  18751. created by autocreate.<br>
  18752. For Eltako devices attributes must be set manually. Eltako devices only send on/off.
  18753. </li>
  18754. <br><br>
  18755. <li>Gateway (EEP A5-38-08)<br>
  18756. Dimming<br>
  18757. [Eltako FUD14, FUD61, FUD70, FSG14, ...]<br>
  18758. <ul>
  18759. <li>on</li>
  18760. <li>off</li>
  18761. <li>block: lock|unlock</li>
  18762. <li>dim: dim/% (Sensor Range: dim = 0 % ... 100 %)</li>
  18763. <li>dimValueLast: dim/%<br>
  18764. Last value received from the bidirectional dimmer.</li>
  18765. <li>dimValueStored: dim/%<br>
  18766. Last value saved by <code>set &lt;name&gt; dim &lt;value&gt;</code>.</li>
  18767. <li>rampTime: t/s (Sensor Range: t = 1 s ... 255 s or 0 if no time specified,
  18768. for Eltako: t = 1 = fast dimming ... 255 = slow dimming or 0 = dimming speed on the dimmer used)</li>
  18769. <li>teach: &lt;result of teach procedure&gt;</li>
  18770. <li>state: on|off</li>
  18771. </ul><br>
  18772. The attr subType must be gateway, gwCmd must be dimming and attr manufID must be 00D
  18773. for Eltako Devices. This is done if the device was created by autocreate.<br>
  18774. For Eltako devices attributes must be set manually. Eltako devices only send on/off and dim.
  18775. </li>
  18776. <br><br>
  18777. <li>Gateway (EEP A5-38-08)<br>
  18778. Setpoint shift<br>
  18779. [untested]<br>
  18780. <ul>
  18781. <li>1/K</li>
  18782. <li>setpointShift: 1/K (Sensor Range: T = -12.7 K ... 12.8 K)</li>
  18783. <li>teach: &lt;result of teach procedure&gt;</li>
  18784. <li>state: 1/K</li>
  18785. </ul><br>
  18786. The attr subType must be gateway, gwCmd must be setpointShift.
  18787. This is done if the device was created by autocreate.
  18788. </li>
  18789. <br><br>
  18790. <li>Gateway (EEP A5-38-08)<br>
  18791. Basic Setpoint<br>
  18792. [untested]<br>
  18793. <ul>
  18794. <li>t/&#176C</li>
  18795. <li>setpoint: t/&#176C (Sensor Range: t = 0 &#176C ... 51.2 &#176C)</li>
  18796. <li>teach: &lt;result of teach procedure&gt;</li>
  18797. <li>state: t/&#176C</li>
  18798. </ul><br>
  18799. The attr subType must be gateway, gwCmd must be setpointBasic.
  18800. This is done if the device was created by autocreate.
  18801. </li>
  18802. <br><br>
  18803. <li>Gateway (EEP A5-38-08)<br>
  18804. Control variable<br>
  18805. [untested]<br>
  18806. <ul>
  18807. <li>auto|heating|cooling|off</li>
  18808. <li>controlVar: cvov (Sensor Range: cvov = 0 % ... 100 %)</li>
  18809. <li>controllerMode: auto|heating|cooling|off</li>
  18810. <li>controllerState: auto|override</li>
  18811. <li>energyHoldOff: normal|holdoff</li>
  18812. <li>presence: present|absent|standby</li>
  18813. <li>teach: &lt;result of teach procedure&gt;</li>
  18814. <li>state: auto|heating|cooling|off</li>
  18815. </ul><br>
  18816. The attr subType must be gateway, gwCmd must be controlVar.
  18817. This is done if the device was created by autocreate.
  18818. </li>
  18819. <br><br>
  18820. <li>Gateway (EEP A5-38-08)<br>
  18821. Fan stage<br>
  18822. [untested]<br>
  18823. <ul>
  18824. <li>0 ... 3|auto</li>
  18825. <li>teach: &lt;result of teach procedure&gt;</li>
  18826. <li>state: 0 ... 3|auto</li>
  18827. </ul><br>
  18828. The attr subType must be gateway, gwCmd must be fanStage.
  18829. This is done if the device was created by autocreate.
  18830. </li>
  18831. <br><br>
  18832. <li>Extended Lighting Control (EEP A5-38-09)<br>
  18833. [untested]<br>
  18834. <ul>
  18835. <li>on</li>
  18836. <li>off</li>
  18837. <li>block: unlock|on|off|local</li>
  18838. <li>blue: &lt;blue channel value&gt; (Range: blue = 0 ... 255)</li>
  18839. <li>dimMax: &lt;maximum dimming value&gt; (Range: dim = 0 ... 255)</li>
  18840. <li>dimMin: &lt;minimum dimming value&gt; (Range: dim = 0 ... 255)</li>
  18841. <li>green: &lt;green channel value&gt; (Range: green = 0 ... 255)</li>
  18842. <li>rampTime: t/s (Range: t = 0 s ... 65535 s)</li>
  18843. <li>red: &lt;red channel value&gt; (Range: red = 0 ... 255)</li>
  18844. <li>rgb: RRGGBB (red (R), green (G) or blue (B) color component values: 00 ... FF)</li>
  18845. <li>teach: &lt;result of teach procedure&gt;</li>
  18846. <li>state: on|off</li>
  18847. </ul><br>
  18848. Another readings, see subtype lightCtrlState.02.<br>
  18849. The attr subType or subTypSet must be lightCtrl.01. This is done if the device was created by autocreate.<br>
  18850. The subType is associated with the subtype lightCtrlState.02.
  18851. </li>
  18852. <br><br>
  18853. <li>Manufacturer Specific Applications (EEP A5-3F-7F)<br><br>
  18854. Wireless Analog Input Module<br>
  18855. [Thermokon SR65 3AI, untested]<br>
  18856. <ul>
  18857. <li>I1: U/V I2: U/V I3: U/V</li>
  18858. <li>input1: U/V (Sensor Range: U = 0 V ... 10 V)</li>
  18859. <li>input2: U/V (Sensor Range: U = 0 V ... 10 V)</li>
  18860. <li>input3: U/V (Sensor Range: U = 0 V ... 10 V)</li>
  18861. <li>teach: &lt;result of teach procedure&gt;</li>
  18862. <li>state: I1: U/V I2: U/V I3: U/V</li>
  18863. </ul><br>
  18864. The attr subType must be manufProfile and attr manufID must be 002
  18865. for Thermokon Devices. This is done if the device was
  18866. created by autocreate.
  18867. </li>
  18868. <br><br>
  18869. <li>Manufacturer Specific Applications (EEP A5-3F-7F)<br><br>
  18870. Thermostat Actuator<br>
  18871. [AWAG omnio UPH230/1x]<br>
  18872. <ul>
  18873. <li>on|off</li>
  18874. <li>emergencyMode&lt;channel&gt;: on|off</li>
  18875. <li>nightReduction&lt;channel&gt;: on|off</li>
  18876. <li>setpointTemp&lt;channel&gt;: t/&#176C</li>
  18877. <li>teach: &lt;result of teach procedure&gt;</li>
  18878. <li>temperature&lt;channel&gt;: t/&#176C</li>
  18879. <li>window&lt;channel&gt;: on|off</li>
  18880. <li>state: on|off</li>
  18881. </ul><br>
  18882. The attr subType must be manufProfile and attr manufID must be 005
  18883. for AWAG omnio Devices. This is done if the device was created by autocreate.
  18884. </li>
  18885. <br><br>
  18886. <li>Manufacturer Specific Applications (EEP A5-3F-7F)<br><br>
  18887. Shutter (EEP F6-02-01 ... F6-02-02)<br>
  18888. [Eltako FSB12, FSB14, FSB61, FSB70]<br>
  18889. <ul>
  18890. <li>open|open_ack<br>
  18891. The status of the device will become "open" after the TOP endpoint is
  18892. reached, or it has finished an "opens" or "position 0" command.</li>
  18893. <li>closed<br>
  18894. The status of the device will become "closed" if the BOTTOM endpoint is
  18895. reached</li>
  18896. <li>stop<br>
  18897. The status of the device become "stop" if stop command is sent.</li>
  18898. <li>not_reached<br>
  18899. The status of the device become "not_reached" between one of the endpoints.</li>
  18900. <li>anglePos: &alpha;/&#176 (Sensor Range: &alpha; = -180 &#176 ... 180 &#176)</li>
  18901. <li>endPosition: open|open_ack|closed|not_reached|not_available</li>
  18902. <li>position: pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  18903. <li>teach: &lt;result of teach procedure&gt;</li>
  18904. <li>state: open|open_ack|closed|not_reached|stop|teach</li>
  18905. </ul><br>
  18906. The values of the reading position and anglePos are updated automatically,
  18907. if the command position is sent or the reading state was changed
  18908. manually to open or closed.<br>
  18909. Set attr subType file, attr manufID to 00D and attr model to
  18910. FSB14|FSB61|FSB70 manually.
  18911. </li>
  18912. <br><br>
  18913. <li>Electronic switches and dimmers with Energy Measurement and Local Control (D2-01-00 - D2-01-12)<br>
  18914. [Telefunken Funktionsstecker, PEHA Easyclick, AWAG Elektrotechnik AG Omnio UPS 230/xx,UPD 230/xx]<br>
  18915. <ul>
  18916. <li>on</li>
  18917. <li>off</li>
  18918. <li>autoOffTime&lt;1...29|All|Input&gt;: 1/s</li>
  18919. <li>channel&lt;0...29|All|Input&gt;: on|off</li>
  18920. <li>delayOffTime&lt;1...29|All|Input&gt;: 1/s</li>
  18921. <li>dayNight: day|night</li>
  18922. <li>defaultState: on|off|last</li>
  18923. <li>devTemp: t/&#176C|invalid</li>
  18924. <li>devTempState: ok|max|warning</li>
  18925. <li>dim&lt;0...29|Input&gt;: dim/% (Sensor Range: dim = 0 % ... 100 %)</li>
  18926. <li>energy&lt;channel&gt;: E/[Ws|Wh|KWh]</li>
  18927. <li>energyUnit&lt;channel&gt;: Ws|Wh|KWh</li>
  18928. <li>error&lt;channel&gt;: ok|warning|failure|not_supported</li>
  18929. <li>extSwitchMode&lt;1...29|All|Input&gt;: unavailable|switch|pushbutton|auto</li>
  18930. <li>extSwitchType&lt;1...29|All|Input&gt;: toggle|direction</li>
  18931. <li>firmwareVersion: [000000 ... FFFFFF]</li>
  18932. <li>loadClassification: no</li>
  18933. <li>localControl&lt;channel&gt;: enabled|disabled</li>
  18934. <li>loadLink: connected|disconnected</li>
  18935. <li>loadOperation: 3-wire</li>
  18936. <li>loadState: on|off</li>
  18937. <li>measurementMode: energy|power</li>
  18938. <li>measurementReport: auto|query</li>
  18939. <li>measurementReset: not_active|trigger</li>
  18940. <li>measurementDelta: E/[Ws|Wh|KWh|W|KW]</li>
  18941. <li>measurementUnit: Ws|Wh|KWh|W|KW</li>
  18942. <li>overCurrentOff&lt;channel&gt;: executed|ready</li>
  18943. <li>overCurrentShutdown&lt;channel&gt;: off|restart</li>
  18944. <li>overCurrentShutdownReset&lt;channel&gt;: not_active|trigger</li>
  18945. <li>power&lt;channel&gt;: P/[W|KW]</li>
  18946. <li>powerFailure&lt;channel&gt;: enabled|disabled</li>
  18947. <li>powerFailureDetection&lt;channel&gt;: detected|not_detected</li>
  18948. <li>powerUnit&lt;channel&gt;: W|KW</li>
  18949. <li>rampTime&lt;1...3l&gt;: 1/s</li>
  18950. <li>responseTimeMax: 1/s</li>
  18951. <li>responseTimeMin: 1/s</li>
  18952. <li>roomCtrlMode: off|comfort|comfort-1|comfort-2|economy|buildingProtection</li>
  18953. <li>serialNumber: [00000000 ... FFFFFFFF]</li>
  18954. <li>taughtInDevID&lt;00...23&gt;: [00000001 ... FFFFFFFE]</li>
  18955. <li>taughtInDevNum: [0 ... 23]</li>
  18956. <li>teach: &lt;result of teach procedure&gt;</li>
  18957. <li>teachInDev: enabled|disabled</li>
  18958. <li>state: on|off</li>
  18959. </ul>
  18960. <br>
  18961. The attr subType must be actuator.01. This is done if the device was
  18962. created by autocreate. To control the device, it must be bidirectional paired,
  18963. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  18964. </li>
  18965. <br><br>
  18966. <li>Blind Control for Position and Angle (D2-05-00)<br>
  18967. [AWAG Elektrotechnik AG OMNIO UPJ 230/12]<br>
  18968. <ul>
  18969. <li>open<br>
  18970. The status of the device will become "open" after the TOP endpoint is
  18971. reached, or it has finished an "opens" or "position 0" command.</li>
  18972. <li>closed<br>
  18973. The status of the device will become "closed" if the BOTTOM endpoint is
  18974. reached</li>
  18975. <li>stop<br>
  18976. The status of the device become "stop" if stop command is sent.</li>
  18977. <li>not_reached<br>
  18978. The status of the device become "not_reached" between one of the endpoints.</li>
  18979. <li>pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  18980. <li>anglePos&lt;channel&gt;: &alpha;/% (Sensor Range: &alpha; = 0 % ... 100 %)</li>
  18981. <li>block&lt;channel&gt;: unlock|lock|alarm</li>
  18982. <li>endPosition&lt;channel&gt;: open|closed|not_reached|unknown</li>
  18983. <li>position&lt;channel&gt;: unknown|pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  18984. <li>teach: &lt;result of teach procedure&gt;</li>
  18985. <li>state: open|closed|in_motion|stopped|pos/% (Sensor Range: pos = 0 % ... 100 %)</li>
  18986. </ul>
  18987. <br>
  18988. The attr subType must be blindsCtrl.00 or blindsCtrl.01. This is done if the device was
  18989. created by autocreate. To control the device, it must be bidirectional paired,
  18990. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  18991. </li>
  18992. <br><br>
  18993. <li>Multisensor Window Handle (D2-06-01)<br>
  18994. [Soda GmbH]<br>
  18995. <ul>
  18996. <li>T: t/&#176C H: -|rH/% E: -|E/lx M: off|on|invalid|not_supported|unknown</li>
  18997. <li>alarms: &lt;alarms&gt; (Range: alarms = 00000000 ... FFFFFFFF)</li>
  18998. <li>battery: ok|low</li>
  18999. <li>batteryLowClick: enabled|disabled</li>
  19000. <li>burglaryAlarm: off|on|invalid|not_supported|unknown</li>
  19001. <li>handle: up|down|left|right|invalid|not_supported|unknown</li>
  19002. <li>blinkInterval: t/s|unknown (Range: t = 3 s ... 255 s)</li>
  19003. <li>blinkIntervalSet: t/s|unknown (Range: t = 3 s ... 255 s)</li>
  19004. <li>brightness: E/lx|over_range|invalid|not_supported|unknown (Sensor Range: E = 0 lx ... 60000 lx)</li>
  19005. <li>buttonLeft: pressed|released|invalid|not_supported|unknown</li>
  19006. <li>buttonLeftPresses: &lt;buttonLeftPresses&gt; (Range: buttonLeftPresses = 00000000 ... FFFFFFFF)</li>
  19007. <li>buttonRight: pressed|released|invalid|not_supported|unknown</li>
  19008. <li>buttonRightPresses: &lt;buttonRightPresses&gt; (Range: buttonRightPresses = 00000000 ... FFFFFFFF)</li>
  19009. <li>energyStorage: 1/%|unknown</li>
  19010. <li>handleClosedClick: enabled|disabled</li>
  19011. <li>handleMoveClosed: &lt;handleMoveClosed&gt; (Range: handleMoveClosed = 00000000 ... FFFFFFFF)</li>
  19012. <li>handleMoveOpend: &lt;handleMoveOpend&gt; (Range: handleMoveOpend = 00000000 ... FFFFFFFF)</li>
  19013. <li>handleMoveTilted: &lt;handleMoveTilted&gt; (Range: handleMoveTilted = 00000000 ... FFFFFFFF)</li>
  19014. <li>humidity: rH/%|invalid|not_supported|unknown</li>
  19015. <li>motion: off|on|invalid|not_supported|unknown</li>
  19016. <li>powerOns: &lt;powerOns&gt; (Range: powerOns = 00000000 ... FFFFFFFF)</li>
  19017. <li>presence: absent|present|invalid|not_supported|unknown</li>
  19018. <li>protectionAlarm: off|on|invalid|not_supported|unknown</li>
  19019. <li>temperature: t/&#176C|invalid|not_supported|unknown (Sensor Range: t = -20 &#176C ... 60 &#176C)</li>
  19020. <li>updateInterval: t/s|unknown (Range: t = 5 s ... 65535 s)</li>
  19021. <li>updateIntervalSet: t/s|unknown (Range: t = 5 s ... 65535 s)</li>
  19022. <li>waitingCmds: &lt;integer number&gt;</li>
  19023. <li>window: undef|not_tilted|tilted|invalid|not_supported|unknown</li>
  19024. <li>windowTilts: &lt;windowTilts&gt; (Range: windowTilts = 00000000 ... FFFFFFFF)</li>
  19025. <li>state: T: t/&#176C H: -|rH/% E: -|E/lx M: off|on|invalid|not_supported|unknown</li>
  19026. </ul><br>
  19027. The attr subType must be multisensor.01. This is done if the device was
  19028. created by autocreate. To control the device, it must be bidirectional paired,
  19029. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19030. </li>
  19031. <br><br>
  19032. <li>Room Control Panels (D2-10-00 - D2-10-02)<br>
  19033. [Kieback & Peter RBW322-FTL]<br>
  19034. <ul>
  19035. <li>T: t/&#176C H: -|rH/% F: 0 ... 100/% SPT: t/&#176C O: -|absent|present M: -|on|off</li>
  19036. <li>battery: ok|low|empty|-</li>
  19037. <li>cooling: auto|on|off|-</li>
  19038. <li>customWarning[1|2]: on|off</li>
  19039. <li>fanSpeed: 0 ... 100/%</li>
  19040. <li>fanSpeedMode: central|local</li>
  19041. <li>heating: auto|on|off|-</li>
  19042. <li>humidity: -|rH/%</li>
  19043. <li>moldWarning: on|off</li>
  19044. <li>motion: on|off|-</li>
  19045. <li>occupancy: -|absent|present</li>
  19046. <li>roomCtrlMode: buildingProtection|comfort|economy|preComfort</li>
  19047. <li>setpointBuildingProtectionTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19048. <li>setpointComfortTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19049. <li>setpointEconomyTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19050. <li>setpointPreComfortTemp: -|t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19051. <li>setpointTemp: t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19052. <li>solarPowered: yes|no</li>
  19053. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  19054. <li>window: closed|open</li>
  19055. <li>state: T: t/&#176C H: -|rH/% F: 0 ... 100/% SPT: t/&#176C O: -|absent|present M: -|on|off</li>
  19056. </ul><br>
  19057. The attr subType must be roomCtrlPanel.00. This is done if the device was
  19058. created by autocreate. To control the device, it must be bidirectional paired,
  19059. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19060. </li>
  19061. <br><br>
  19062. <li>Room Control Panels (D2-11-01 - D2-11-08)<br>
  19063. [Thermokon EasySens SR06 LCD-2T/-2T rh -4T/-4T rh]<br>
  19064. <ul>
  19065. <li>T: t/&#176C H: rH/% SPT: t/&#176C F: auto|off|1|2|3</li>
  19066. <li>cooling: on|off</li>
  19067. <li>fanSpeed: auto|off|1|2|3</li>
  19068. <li>heating: on|off</li>
  19069. <li>humidity: rH/%</li>
  19070. <li>occupancy: occupied|unoccupied</li>
  19071. <li>setpointBase: t/&#176C (Range: t = 15 &#176C ... 30 &#176C)</li>
  19072. <li>setpointShift: t/K (Range: t = -10 K ... 10 K)</li>
  19073. <li>setpointShiftMax: t/K (Range: t = 0 K ... 10 K)</li>
  19074. <li>setpointTemp: t/&#176C (Range: t = 5 &#176C ... 40 &#176C)</li>
  19075. <li>setpointType: setpointTemp|setpointShift</li>
  19076. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  19077. <li>trigger: heartbeat|sensor|input</li>
  19078. <li>window: closed|open</li>
  19079. <li>state: T: t/&#176C H: rH/% SPT: t/&#176C F: auto|off|1|2|3</li>
  19080. </ul><br>
  19081. The attr subType must be roomCtrlPanel.01. This is done if the device was
  19082. created by autocreate. To control the device, it must be bidirectional paired by Smart Ack,
  19083. see <a href="#EnOcean_smartAck">SmartAck Learning</a>.
  19084. </li>
  19085. <br><br>
  19086. <li>Fan Control (D2-20-00 - D2-20-02)<br>
  19087. [Maico ECA x RC/RCH, ER 100 RC, untested]<br>
  19088. <ul>
  19089. <li>on|off|not_supported</li>
  19090. <li>fanSpeed: 0 ... 100/%</li>
  19091. <li>error: ok|air_filter|hardware|not_supported</li>
  19092. <li>humidity: rH/%|not_supported</li>
  19093. <li>humidityCtrl: disabled|enabled|not_supported</li>
  19094. <li>roomSize: 0...350/m<sup>2</sup>|max</li>
  19095. <li>roomSizeRef: unsed|not_used|not_supported</li>
  19096. <li>setpointTemp: t/&#176C (Range: t = 0 &#176C ... 40 &#176C)</li>
  19097. <li>teach: &lt;result of teach procedure&gt;</li>
  19098. <li>temperature: t/&#176C (Sensor Range: t = 0 &#176C ... 40 &#176C)</li>
  19099. <li>state: on|off|not_supported</li>
  19100. </ul><br>
  19101. The attr subType must be fanCtrl.00. This is done if the device was
  19102. created by autocreate. To control the device, it must be bidirectional paired,
  19103. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19104. </li>
  19105. <br><br>
  19106. <li>AC Current Clamp (D2-32-00 - D2-32-02)<br>
  19107. [untested]<br>
  19108. <ul>
  19109. <li>I1: I/A I2: I/A I3: I/A</li>
  19110. <li>current1: I/A (Range: I = 0 A ... 4095 A)</li>
  19111. <li>current2: I/A (Range: I = 0 A ... 4095 A)</li>
  19112. <li>current3: I/A (Range: I = 0 A ... 4095 A)</li>
  19113. <li>teach: &lt;result of teach procedure&gt;</li>
  19114. <li>state: I1: I/A I2: I/A I3: I/A</li>
  19115. </ul><br>
  19116. The attr subType must be currentClamp.00|currentClamp.01|currentClamp.02. This is done if the device was
  19117. created by autocreate.
  19118. </li>
  19119. <br><br>
  19120. <li>LED Controller Status (EEP D2-40-00 - D2-40-01)<br>
  19121. [untested]<br>
  19122. <ul>
  19123. <li>on|off</li>
  19124. <li>blue: 0 % ... 100 %</li>
  19125. <li>daylightHarvesting: on|off</li>
  19126. <li>demandResp: on|off</li>
  19127. <li>dim: 0 % ... 100 %</li>
  19128. <li>green: 0 % ... 100 %</li>
  19129. <li>occupany: unoccupied|occupied|unknown</li>
  19130. <li>powerSwitch: on|off</li>
  19131. <li>red: 0 % ... 100 %</li>
  19132. <li>rgb: RRGGBB (red (R), green (G) or blue (B) color component values: 00 ... FF)</li>
  19133. <li>teach: &lt;result of teach procedure&gt;</li>
  19134. <li>telegramType: event|heartbeat</li>
  19135. <li>state: on|off</li>
  19136. </ul><br>
  19137. The attr subType must be ledCtrlState.00|ledCtrlState.01 This is done if the device was
  19138. created by autocreate.
  19139. </li>
  19140. <br><br>
  19141. <li>Heat Recovery Ventilation (D2-50-00 - D2-50-11)<br>
  19142. [untested]<br>
  19143. <ul>
  19144. <li>off|1...4|auto|demand|supplyAir|exhaustAir</li>
  19145. <li>airQualidity1: 1/%</li>
  19146. <li>airQualidity2: 1/%</li>
  19147. <li>airQualidityThreshold: default|1/%</li>
  19148. <li>CO2Threshold: default|1/%</li>
  19149. <li>coolingProtection: on|off</li>
  19150. <li>defrost: on|off</li>
  19151. <li>deviceMode: master|slave</li>
  19152. <li>drainHeater: on|off</li>
  19153. <li>exhaustAirFlap: closed|opend</li>
  19154. <li>exhaustAirFlow: h/m3 (Sensor Range: Q = 0 m3/h ... 1023 m3/h)</li>
  19155. <li>exhaustFanSpeed: min (Sensor Range: n = 0 / min ... 4095 / min)</li>
  19156. <li>exhaustTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19157. <li>fault: bbbbbbbb bbbbbbbb bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19158. <li>filterMaintenance: required|not_required</li>
  19159. <li>fireplaceSafetyMode: disabled|enabled</li>
  19160. <li>heatExchangerBypass: closed|opend</li>
  19161. <li>humidityThreshold: default|rH/%</li>
  19162. <li>info: bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19163. <li>input: bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19164. <li>operationHours: [0 ... 589815]</li>
  19165. <li>output: bbbbbbbb bbbbbbbb (b = 0|1)</li>
  19166. <li>outdoorAirHeater: on|off</li>
  19167. <li>outdoorTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19168. <li>roomTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19169. <li>roomTempCtrl: on|off</li>
  19170. <li>roomTempSet: default|t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19171. <li>supplyAirFlow: h/m3 (Sensor Range: Q = 0 m3/h ... 1023 m3/h)</li>
  19172. <li>supplyAirFlap: closed|opend</li>
  19173. <li>supplyAirHeater: on|off</li>
  19174. <li>supplyFanSpeed: min (Sensor Range: n = 0 / min ... 4095 / min)</li>
  19175. <li>supplyTemp: t/&#176C (Sensor Range: t = -63 &#176C ... 63 &#176C)</li>
  19176. <li>SWVersion: [0 ... 4095]</li>
  19177. <li>timerMode: on|off</li>
  19178. <li>weeklyTimer: on|off</li>
  19179. <li>state: off|1...4|auto|demand|supplyAir|exhaustAir</li>
  19180. </ul><br>
  19181. The attr subType must be heatRecovery.00. This is done if the device was
  19182. created by autocreate. To control the device, it must be bidirectional paired,
  19183. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19184. </li>
  19185. <br><br>
  19186. <li>Valve Control (EEP D2-A0-01)<br>
  19187. <ul>
  19188. <li>opens</li>
  19189. <li>open</li>
  19190. <li>closes</li>
  19191. <li>closed</li>
  19192. <li>teach: &lt;result of teach procedure&gt;</li>
  19193. <li>state: opens|open|closes|closed|teachIn|teachOut</li>
  19194. </ul><br>
  19195. The attr subType must be valveCtrl.00. This is done if the device was
  19196. created by autocreate. To control the device, it must be bidirectional paired,
  19197. see <a href="#EnOcean_teach-in">Bidirectional Teach-In / Teach-Out</a>.
  19198. </li>
  19199. <br><br>
  19200. <li>Liquid Leakage Sensor (EEP D2-B0-51)<br>
  19201. [untested]<br>
  19202. <ul>
  19203. <li>dry</li>
  19204. <li>wet</li>
  19205. <li>state: dry|wet</li>
  19206. </ul><br>
  19207. The attr subType must be liquidLeakage.51. This is done if the device was
  19208. created by autocreate.
  19209. </li>
  19210. <br><br>
  19211. <li>Generic Profiles<br>
  19212. <ul>
  19213. <li>&lt;00...64&gt;-&lt;channel name&gt;: &lt;value&gt;</li>
  19214. <li>&lt;00...64&gt;-&lt;channel name&gt;Unit: &lt;value&gt;</li>
  19215. <li>&lt;00...64&gt;-&lt;channel name&gt;ValueType: value|setpointAbs|setpointRel</li>
  19216. <li>&lt;00...64&gt;-&lt;channel name&gt;ChannelType: teachIn|data|flag|enum</li>
  19217. <li>teach: &lt;result of teach procedure&gt;</li>
  19218. </ul><br>
  19219. The attr subType must be genericProfile. This is done if the device was
  19220. created by autocreate. If the profile in slave mode is operated, especially the channel
  19221. definition in the gpDef attributes must be entered manually.
  19222. </li>
  19223. <br><br>
  19224. <li>RAW Command<br>
  19225. <ul>
  19226. <li>RORG: 1BS|4BS|ENC|MCS|RPS|SEC|STE|UTE|VLD</li>
  19227. <li>dataSent: data (Range: 1 Byte hex ... 512 Byte hex)</li>
  19228. <li>statusSent: status (Range: 0x00 ... 0xFF)</li>
  19229. <li>state: RORG: rorg DATA: data STATUS: status ODATA: odata</li>
  19230. </ul><br>
  19231. With the help of this command data messages in hexadecimal format can be sent and received.
  19232. The telegram types (RORG) 1BS and RPS are always received protocol-specific.
  19233. For further information, see
  19234. <a href="http://www.enocean-alliance.org/eep/">EnOcean Equipment Profiles (EEP)</a>.
  19235. <br>
  19236. Set attr subType to raw manually.
  19237. </li>
  19238. <br><br>
  19239. <li>Light and Presence Sensor<br>
  19240. [Omnio Ratio eagle-PM101]<br>
  19241. <ul>
  19242. <li>on</li>
  19243. <li>off</li>
  19244. <li>brightness: E/lx (Sensor Range: E = 0 lx ... 1000 lx)</li>
  19245. <li>channel1: on|off<br>
  19246. Motion message in depending on the brightness threshold</li>
  19247. <li>channel2: on|off<br>
  19248. Motion message</li>
  19249. <li>motion: on|off<br>
  19250. Channel 2</li>
  19251. <li>state: on|off<br>
  19252. Channel 2</li>
  19253. </ul><br>
  19254. The sensor also sends switching commands (RORG F6) with the SenderID-1.<br>
  19255. Set attr subType to PM101 manually. Automatic teach-in is not possible,
  19256. since no EEP and manufacturer ID are sent.
  19257. </li>
  19258. <br><br>
  19259. <li>Radio Link Test<br>
  19260. <ul>
  19261. <li>standby|active|stopped</li>
  19262. <li>msgLost: msgLost/%</li>
  19263. <li>rssiMasterAvg: LP/dBm</li>
  19264. <li>state: standby|active|stopped<br></li>
  19265. </ul><br>
  19266. The attr subType must be readioLinkTest. This is done if the device was
  19267. created by autocreate or manually by <code>define &lt;name&gt; EnOcean A5-3F-00</code><br>.
  19268. </li>
  19269. </ul>
  19270. </ul>
  19271. =end html
  19272. =cut