UNPKG

@strato-automation/node-red-contrib-strato-automation

Version:
1 lines 11.9 kB
function a16_0x4916(_0x9a492c,_0x227c1e){const _0x566d20=a16_0x566d();return a16_0x4916=function(_0x49169f,_0x19ecd0){_0x49169f=_0x49169f-0x170;let _0x59fff5=_0x566d20[_0x49169f];return _0x59fff5;},a16_0x4916(_0x9a492c,_0x227c1e);}function a16_0x566d(){const _0xb2842e=['_resolution','writeIpObject','8829534RAbCjQ','Disconnected\x20:\x20','json','is_mqtt_connected','push','__mqtt_topic','_actual_value','send','https://','object_type','\x20Requested\x20:\x20','yellow','status','ocn_ip','set_status','Error\x20getting\x20object\x20value','interval','Connected\x20:\x20','toUpperCase','payload','__use_static_object_id','__out','grey','resolution','HTTP\x20status\x20:\x20','783046oHrWTG','catch','__use_static_device_instance','bypass_priority','red','dot','/api/v1','getNode','4402638FonJQn','unsubscribeNode','nodes','handleMQTTMessage','1627776GlTIbn','ring','No\x20server\x20selected','Error\x20parsing\x20JSON:\x20','registerType','Value','topic','object_id','get','device_instance','14166OWCdSm','subscribeNode','writeMstpObject','telemetry/','toFixed','_requested_value','Actual\x20:\x20','14691681heIRsm','__writeObject','mqtt_connect','abs','ocn_server_node','show_status','close','type','context','log','once','global','410900YitKjo','subscribe','No\x20server\x20node\x20configured','parse','Subscribing\x20to\x20','_service','output_type','440pjaNzA','then','8DcIoLf','object_instance','connectionId','priority','presentValue','ocn-server','error','source','split','api_token','api','mqtt','getShallowObject','Waiting'];a16_0x566d=function(){return _0xb2842e;};return a16_0x566d();}(function(_0x6caa9e,_0xccdde9){const _0x1769c8=a16_0x4916,_0x2439e6=_0x6caa9e();while(!![]){try{const _0x334308=parseInt(_0x1769c8(0x17f))/0x1+parseInt(_0x1769c8(0x18b))/0x2+-parseInt(_0x1769c8(0x195))/0x3*(-parseInt(_0x1769c8(0x1af))/0x4)+-parseInt(_0x1769c8(0x1a8))/0x5+-parseInt(_0x1769c8(0x187))/0x6+-parseInt(_0x1769c8(0x1c1))/0x7*(-parseInt(_0x1769c8(0x1b1))/0x8)+-parseInt(_0x1769c8(0x19c))/0x9;if(_0x334308===_0xccdde9)break;else _0x2439e6['push'](_0x2439e6['shift']());}catch(_0x19676a){_0x2439e6['push'](_0x2439e6['shift']());}}}(a16_0x566d,0xe2e4a),module['exports']=function(_0x44fcf4){const _0x198cbb=a16_0x4916,_0x2f1b42=require('../lib/ocnApiClient.js');function _0x2c3a93(_0x2142dd){const _0x4f7945=a16_0x4916;_0x44fcf4['nodes']['createNode'](this,_0x2142dd);var _0x512e00=this;_0x512e00[_0x4f7945(0x1a0)]=_0x44fcf4['nodes']['getNode'](_0x2142dd[_0x4f7945(0x1a0)]),_0x512e00['priority']=_0x2142dd[_0x4f7945(0x1b4)]||'16';_0x2142dd[_0x4f7945(0x194)]&&_0x2142dd['device_instance']!=''?(_0x512e00[_0x4f7945(0x181)]=!![],_0x512e00[_0x4f7945(0x194)]=_0x2142dd[_0x4f7945(0x194)]):_0x512e00['__use_static_device_instance']=![];_0x2142dd['object_id']&&_0x2142dd['object_id']!=''?(_0x512e00[_0x4f7945(0x17a)]=!![],_0x512e00[_0x4f7945(0x192)]=_0x2142dd[_0x4f7945(0x192)],_0x512e00[_0x4f7945(0x1ca)]=_0x2142dd['object_id'][_0x4f7945(0x1b9)]('-')[0x0],_0x512e00[_0x4f7945(0x1b2)]=_0x2142dd[_0x4f7945(0x192)][_0x4f7945(0x1b9)]('-')[0x1]):_0x512e00[_0x4f7945(0x17a)]=![];_0x512e00[_0x4f7945(0x1b8)]=_0x2142dd[_0x4f7945(0x1b8)]||_0x4f7945(0x1bc),_0x512e00['source']=_0x512e00['source']===''?_0x4f7945(0x1bc):_0x512e00[_0x4f7945(0x1b8)],_0x512e00[_0x4f7945(0x1ae)]=_0x2142dd['output_type']||'ip',_0x512e00[_0x4f7945(0x182)]=_0x2142dd['bypass_priority']||![],_0x512e00['_service']=this[_0x4f7945(0x1a4)]()[_0x4f7945(0x1a7)][_0x4f7945(0x193)]('PresentValueUpdateService'),_0x512e00[_0x4f7945(0x1c7)]=undefined,_0x512e00[_0x4f7945(0x19a)]=undefined,_0x512e00[_0x4f7945(0x1bf)]=0.1,setTimeout(()=>{const _0x5b0f29=_0x4f7945;if(!_0x512e00[_0x5b0f29(0x1a0)]||!_0x512e00[_0x5b0f29(0x181)]||!_0x512e00['__use_static_object_id']||_0x512e00['device_instance']==''||_0x512e00[_0x5b0f29(0x192)]=='')return;_0x512e00['api']=new _0x2f1b42(_0x5b0f29(0x1c9)+_0x512e00['ocn_server_node'][_0x5b0f29(0x173)]+_0x5b0f29(0x185),_0x512e00[_0x5b0f29(0x1a0)]['api_token']);try{_0x512e00[_0x5b0f29(0x1bb)][_0x5b0f29(0x1bd)](_0x512e00['device_instance'],_0x512e00[_0x5b0f29(0x1ca)],_0x512e00['object_instance'])[_0x5b0f29(0x1b0)](_0x21d20d=>{const _0x16493d=_0x5b0f29;_0x21d20d[_0x16493d(0x172)]==0xc8?_0x21d20d[_0x16493d(0x1c3)]()[_0x16493d(0x1b0)](_0x35cf3a=>{const _0x1a7b70=_0x16493d,_0x45a2bb=_0x35cf3a[_0x1a7b70(0x17d)];if(_0x45a2bb&&!isNaN(_0x45a2bb))_0x512e00[_0x1a7b70(0x1bf)]=_0x45a2bb;_0x512e00[_0x1a7b70(0x174)]();}):(_0x512e00[_0x16493d(0x1b7)](_0x16493d(0x175)),_0x512e00['status']({'fill':_0x16493d(0x183),'shape':_0x16493d(0x18c),'text':_0x16493d(0x17e)+_0x21d20d['status']}));})['catch'](_0x2d49a7=>{const _0x360696=_0x5b0f29;_0x512e00[_0x360696(0x1b7)](_0x2d49a7);});}catch(_0x10f84b){_0x512e00['error'](_0x10f84b);}},0x2710);_0x512e00[_0x4f7945(0x181)]&&_0x512e00[_0x4f7945(0x17a)]?_0x512e00[_0x4f7945(0x174)]=function(){const _0x22f692=_0x4f7945;if(_0x512e00[_0x22f692(0x1c7)]===undefined&&_0x512e00['_requested_value']===undefined){_0x512e00[_0x22f692(0x172)]({'fill':_0x22f692(0x17c),'shape':_0x22f692(0x184),'text':_0x22f692(0x1be)});return;}else Math[_0x22f692(0x19f)](_0x512e00['_actual_value']-_0x512e00['_requested_value'])<_0x512e00[_0x22f692(0x1bf)]?_0x512e00[_0x22f692(0x172)]({'fill':'green','shape':'dot','text':_0x22f692(0x19b)+_0x512e00[_0x22f692(0x1c7)]?.['toFixed'](0x2)+_0x22f692(0x170)+_0x512e00['_requested_value']?.[_0x22f692(0x199)](0x2)}):_0x512e00[_0x22f692(0x172)]({'fill':_0x22f692(0x171),'shape':_0x22f692(0x184),'text':_0x22f692(0x19b)+_0x512e00[_0x22f692(0x1c7)]?.[_0x22f692(0x199)](0x2)+_0x22f692(0x170)+_0x512e00[_0x22f692(0x19a)]?.[_0x22f692(0x199)](0x2)});return;}:_0x512e00[_0x4f7945(0x174)]=function(){const _0x49c437=_0x4f7945;_0x512e00[_0x49c437(0x172)]({});};if(_0x2142dd[_0x4f7945(0x1a0)]==''){_0x512e00['warn'](_0x4f7945(0x18d));var _0x201de9=[];_0x44fcf4[_0x4f7945(0x189)]['eachNode'](function(_0x3588c2){const _0x44eed3=_0x4f7945;_0x3588c2[_0x44eed3(0x1a3)]==_0x44eed3(0x1b6)&&_0x201de9[_0x44eed3(0x1c5)](_0x3588c2);}),_0x201de9['length']>0x0?(this['warn']('Using\x20first\x20server\x20node'),_0x2142dd[_0x4f7945(0x1a0)]=_0x201de9[0x0]['id']):this[_0x4f7945(0x1b7)](_0x4f7945(0x1aa));}this[_0x4f7945(0x1a0)]=_0x44fcf4['nodes'][_0x4f7945(0x186)](_0x2142dd[_0x4f7945(0x1a0)]);if(_0x512e00[_0x4f7945(0x181)]&&_0x512e00[_0x4f7945(0x17a)]&&_0x512e00[_0x4f7945(0x1b8)]==_0x4f7945(0x1bc))_0x512e00[_0x4f7945(0x18a)]=function(_0x59772d,_0x4752cd){const _0xf3f1b0=_0x4f7945;try{_0x4752cd=JSON[_0xf3f1b0(0x1ab)](_0x4752cd),_0x512e00[_0xf3f1b0(0x1c7)]=Number(_0x4752cd['Value']),msg={'payload':_0x4752cd[_0xf3f1b0(0x190)],'object_id':_0x512e00[_0xf3f1b0(0x192)],'device_instance':_0x512e00[_0xf3f1b0(0x194)],'object_type':_0x512e00[_0xf3f1b0(0x1ca)],'object_instance':_0x512e00[_0xf3f1b0(0x1b2)],'priority':_0x512e00[_0xf3f1b0(0x1b4)]},_0x512e00['set_status'](),_0x512e00[_0xf3f1b0(0x1c8)]([undefined,msg]);}catch(_0x11e6d5){_0x512e00[_0xf3f1b0(0x1b7)](_0xf3f1b0(0x18e)+_0x11e6d5);}},_0x512e00['subscribe']=function(){const _0x48f629=_0x4f7945;if(!_0x512e00[_0x48f629(0x1a0)]['connectionId']){_0x512e00['ocn_server_node'][_0x48f629(0x1a6)]('ready',_0x512e00[_0x48f629(0x1a9)]);return;}_0x512e00['__mqtt_topic']=_0x48f629(0x198)+_0x512e00[_0x48f629(0x1a0)][_0x48f629(0x1b3)]+'/+/'+_0x512e00[_0x48f629(0x194)]+'/'+_0x512e00[_0x48f629(0x192)][_0x48f629(0x178)](),console[_0x48f629(0x1a5)](_0x48f629(0x1ac)+_0x512e00[_0x48f629(0x1c6)]),_0x512e00[_0x48f629(0x1a0)][_0x48f629(0x196)](_0x512e00[_0x48f629(0x1c6)],_0x512e00[_0x48f629(0x18a)]);},this['ocn_server_node']&&(this[_0x4f7945(0x1a0)][_0x4f7945(0x1c4)]?(_0x512e00[_0x4f7945(0x1a9)](),_0x512e00[_0x4f7945(0x172)]({'fill':'green','shape':'dot','text':_0x4f7945(0x177)+_0x512e00[_0x4f7945(0x191)]})):(_0x512e00[_0x4f7945(0x172)]({'fill':_0x4f7945(0x183),'shape':_0x4f7945(0x18c),'text':_0x4f7945(0x1c2)+_0x512e00[_0x4f7945(0x191)]}),this[_0x4f7945(0x1a0)]['on'](_0x4f7945(0x19e),function(){const _0x36f6a3=_0x4f7945;_0x512e00['subscribe'](),_0x512e00[_0x36f6a3(0x172)]({'fill':'green','shape':_0x36f6a3(0x184),'text':_0x36f6a3(0x177)+_0x512e00[_0x36f6a3(0x191)]});})));else{if(_0x512e00[_0x4f7945(0x181)]&&_0x512e00[_0x4f7945(0x17a)]&&_0x512e00[_0x4f7945(0x1b8)]==_0x4f7945(0x1bb)){if(!_0x512e00[_0x4f7945(0x1a0)])return;_0x512e00[_0x4f7945(0x1bb)]=new _0x2f1b42('https://'+_0x512e00[_0x4f7945(0x1a0)]['ocn_ip']+_0x4f7945(0x185),_0x512e00[_0x4f7945(0x1a0)][_0x4f7945(0x1ba)]),_0x512e00[_0x4f7945(0x176)]=setInterval(()=>{const _0x39af60=_0x4f7945;try{_0x512e00[_0x39af60(0x1bb)][_0x39af60(0x1bd)](_0x512e00[_0x39af60(0x194)],_0x512e00[_0x39af60(0x1ca)],_0x512e00[_0x39af60(0x1b2)])[_0x39af60(0x1b0)](_0x329433=>{const _0x3bfd0c=_0x39af60;_0x329433[_0x3bfd0c(0x172)]==0xc8?_0x329433[_0x3bfd0c(0x1c3)]()[_0x3bfd0c(0x1b0)](_0x1c37b3=>{const _0x2cab4f=_0x3bfd0c;_0x512e00[_0x2cab4f(0x1c7)]=Number(_0x1c37b3[_0x2cab4f(0x1b5)]);let _0xddb570={'payload':_0x1c37b3[_0x2cab4f(0x1b5)],'object_id':_0x512e00[_0x2cab4f(0x192)],'device_instance':_0x512e00[_0x2cab4f(0x194)],'object_type':_0x512e00[_0x2cab4f(0x1ca)],'object_instance':_0x512e00[_0x2cab4f(0x1b2)],'priority':_0x512e00[_0x2cab4f(0x1b4)]};_0x512e00[_0x2cab4f(0x174)](),_0x512e00['send']([undefined,_0xddb570]);}):(_0x512e00[_0x3bfd0c(0x1b7)]('Error\x20getting\x20object\x20value'),_0x512e00[_0x3bfd0c(0x172)]({'fill':_0x3bfd0c(0x183),'shape':_0x3bfd0c(0x18c),'text':_0x3bfd0c(0x17e)+_0x329433[_0x3bfd0c(0x172)]}));})[_0x39af60(0x180)](_0x460135=>{_0x512e00['error'](_0x460135);});}catch(_0x92b8b6){_0x512e00[_0x39af60(0x1b7)](_0x92b8b6);}},0x3e8);}}_0x512e00['on'](_0x4f7945(0x1a2),function(){const _0xd4ccde=_0x4f7945;clearInterval(_0x512e00[_0xd4ccde(0x176)]),_0x512e00[_0xd4ccde(0x1a0)]&&_0x512e00[_0xd4ccde(0x1c6)]&&_0x512e00['ocn_server_node'][_0xd4ccde(0x188)](_0x512e00[_0xd4ccde(0x1c6)],_0x512e00[_0xd4ccde(0x18a)]);}),_0x512e00['on']('input',function(_0x3e4861){const _0x4cbb76=_0x4f7945;_0x3e4861['object_id']&&!_0x512e00[_0x4cbb76(0x17a)]&&(_0x512e00[_0x4cbb76(0x192)]=_0x3e4861[_0x4cbb76(0x192)],_0x512e00[_0x4cbb76(0x1ca)]=_0x512e00[_0x4cbb76(0x192)][_0x4cbb76(0x1b9)]('-')[0x0],_0x512e00[_0x4cbb76(0x1b2)]=_0x512e00[_0x4cbb76(0x192)][_0x4cbb76(0x1b9)]('-')[0x1]);_0x3e4861[_0x4cbb76(0x194)]&&!_0x512e00[_0x4cbb76(0x181)]&&(_0x512e00['device_instance']=_0x3e4861[_0x4cbb76(0x194)]);_0x3e4861[_0x4cbb76(0x1b4)]&&_0x512e00[_0x4cbb76(0x182)]&&(_0x512e00[_0x4cbb76(0x1b4)]=_0x3e4861[_0x4cbb76(0x1b4)]);const _0x3e97be=_0x3e4861['payload']===null?null:Number(_0x3e4861[_0x4cbb76(0x179)]);if(_0x3e97be!==null&&isNaN(_0x3e97be))return;_0x512e00[_0x4cbb76(0x17b)]=_0x3e97be,_0x512e00[_0x4cbb76(0x19a)]=_0x3e97be,_0x3e4861[_0x4cbb76(0x192)]=_0x512e00[_0x4cbb76(0x192)],_0x3e4861[_0x4cbb76(0x194)]=_0x512e00[_0x4cbb76(0x194)],_0x3e4861['object_type']=_0x512e00[_0x4cbb76(0x1ca)],_0x3e4861[_0x4cbb76(0x1b2)]=_0x512e00[_0x4cbb76(0x1b2)],_0x3e4861[_0x4cbb76(0x1b4)]=_0x512e00['priority'],this['__writeObject'](),_0x512e00[_0x4cbb76(0x174)](),_0x512e00[_0x4cbb76(0x1c8)]([_0x3e4861,undefined]);}),_0x512e00[_0x4f7945(0x19d)]=function(){const _0x3e204b=_0x4f7945;if(_0x512e00['__out']===undefined)return;_0x512e00[_0x3e204b(0x1ae)]==='ip'?_0x512e00[_0x3e204b(0x1ad)][_0x3e204b(0x1c0)](_0x512e00[_0x3e204b(0x1a0)][_0x3e204b(0x173)],_0x512e00[_0x3e204b(0x1a0)][_0x3e204b(0x1ba)],_0x512e00[_0x3e204b(0x194)],_0x512e00[_0x3e204b(0x1ca)],_0x512e00[_0x3e204b(0x1b2)],{'propertyId':0x55,'priority':Number(_0x512e00[_0x3e204b(0x1b4)]),'value':_0x512e00[_0x3e204b(0x17b)]}):_0x512e00['_service'][_0x3e204b(0x197)](_0x512e00[_0x3e204b(0x1a0)][_0x3e204b(0x173)],_0x512e00[_0x3e204b(0x1a0)][_0x3e204b(0x1ba)],_0x512e00['device_instance'],_0x512e00[_0x3e204b(0x1ca)],_0x512e00[_0x3e204b(0x1b2)],{'propertyId':0x55,'priority':Number(_0x512e00[_0x3e204b(0x1b4)]),'value':_0x512e00[_0x3e204b(0x17b)]});},_0x512e00[_0x4f7945(0x1a1)]&&_0x512e00[_0x4f7945(0x172)]({'fill':_0x4f7945(0x17c),'shape':'dot','text':_0x4f7945(0x1be)});}_0x44fcf4[_0x198cbb(0x189)][_0x198cbb(0x18f)]('output-generic',_0x2c3a93);});