\n\n\n\n\n\n","import Utils from \"@/Utils\";\n\nexport default {\n mixins: [Utils],\n props: {\n /**\n * Component name\n */\n name: {\n type: String,\n default: '[Unnamed sensor]',\n },\n\n /**\n * Action (FontAwesome) icon class (default: `fa fa-play`)\n */\n iconClass: {\n type: String,\n },\n\n /**\n * Action icon URL (default: `fa fa-play`)\n */\n iconUrl: {\n type: String,\n },\n\n /**\n * Action icon color override, for FontAwesome icons\n */\n iconColor: {\n type: String,\n },\n\n /**\n * Actions to run upon interaction with the widget. Format:\n *\n * [\n * {\n * \"action\": \"light.hue.toggle\",\n * \"args\": {\n * \"lights\": [\"Bulb 1\", \"Bulb 2\"]\n * }\n * },\n * {\n * \"action\": \"music.mpd.pause\"\n * }\n * ]\n */\n actions: {\n type: Array,\n default: () => { return [] },\n },\n\n /**\n * Map of variables used by this component, in the form\n * variable_name -> variable_value.\n */\n _vars: {\n type: Object,\n default: () => { return {} },\n },\n\n /**\n * Map of handlers, in the form of event_type -> functions.\n * Supported event handler types:\n *\n * - mounted: Function to execute when the component is mounted.\n * - beforeActions: Function to execute before the component action is run.\n * - afterActions: Function to execute after the component action is run.\n * - refresh: Function to be called at startup (if mounted is also specified\n * then refresh will be called after mounted when the component is\n * first mounted) and at regular intervals defined on the\n * interval property (default: 10 seconds).\n * - events: This is a mapping of functions that react to Platypush\n * platform events published on the websocket (e.g. lights or\n * switches toggles, media events etc.). The form is\n * platypush_event_type -> function.\n */\n handlers: {\n type: Object,\n default: () => { return {} },\n },\n\n /**\n * Event bus\n */\n bus: {\n type: Object,\n },\n },\n\n data() {\n return {\n vars: {...(this._vars || {})},\n _interval: undefined,\n refresh: null,\n refreshInterval: null,\n value: null,\n loading: false,\n }\n },\n\n computed: {\n iconStyle() {\n if (!this.iconClass?.length && this.iconColor?.length)\n return\n\n return {'color': this.iconColor}\n },\n\n hasIcon() {\n return this.iconUrl?.length || this.iconClass?.length\n },\n },\n\n methods: {\n async run() {\n if (this.handlers.input)\n return this.handlers.input(this)(this.value)\n\n if (this.handlers.beforeActions)\n await this.handlers.beforeActions(this)\n for (const action of this.actions)\n await this.request_(action)\n if (this.handlers.afterActions) {\n await this.handlers.afterActions(this)\n }\n },\n\n async request_(action) {\n const args = Object.entries(action.args).reduce((args, [key, value]) => {\n if (value.trim) {\n value = value.trim()\n const m = value.match(/^{{\\s*(.*)\\s*}}/)\n if (m) {\n value = eval(`// noinspection JSUnusedLocalSymbols\n (function (self) {\n return ${m[1]}\n })`)(this)\n }\n }\n\n args[key] = value\n return args\n }, {})\n\n await this.request(action.action, args)\n },\n\n async processEvent(event) {\n const hndl = (this.handlers.events || {})[event.type]\n if (hndl)\n await hndl(this)(event)\n },\n },\n\n async mounted() {\n this.$root.bus.on('event', this.processEvent)\n\n if (this.handlers.mounted)\n await this.handlers.mounted(this)\n\n if (this.handlers.refresh) {\n this.refreshInterval = (this.handlers.refresh?.interval || 0) * 1000\n this.refresh = () => {\n this.handlers.refresh.handler(this)\n }\n\n await this.refresh()\n if (this.refreshInterval) {\n const self = this\n const wrapper = () => { return self.refresh() }\n this._interval = setInterval(wrapper, this.refreshInterval)\n }\n }\n },\n\n unmounted() {\n if (this._interval)\n clearInterval(this._interval)\n }\n}\n","\n
\n
\n \n \n
\n \n
\n\n\n\n\n\n","import { render } from \"./Run.vue?vue&type=template&id=7478b72d&scoped=true\"\nimport script from \"./Run.vue?vue&type=script&lang=js\"\nexport * from \"./Run.vue?vue&type=script&lang=js\"\n\nimport \"./Run.vue?vue&type=style&index=0&id=7478b72d&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-7478b72d\"]])\n\nexport default __exports__","\n
\n
\n \n \n
\n \n
\n
\n {{ value }}\n \n
\n
\n
\n\n\n\n\n\n","import { render } from \"./Sensor.vue?vue&type=template&id=53594122&scoped=true\"\nimport script from \"./Sensor.vue?vue&type=script&lang=js\"\nexport * from \"./Sensor.vue?vue&type=script&lang=js\"\n\nimport \"./Sensor.vue?vue&type=style&index=0&id=53594122&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-53594122\"]])\n\nexport default __exports__","\n
\n
\n \n \n
\n \n
\n
\n \n
\n
\n
\n\n\n\n\n\n","import { render } from \"./Slider.vue?vue&type=template&id=71b842b2&scoped=true\"\nimport script from \"./Slider.vue?vue&type=script&lang=js\"\nexport * from \"./Slider.vue?vue&type=script&lang=js\"\n\nimport \"./Slider.vue?vue&type=style&index=0&id=71b842b2&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-71b842b2\"]])\n\nexport default __exports__","\n
\n
\n \n \n
\n \n
\n
\n \n
\n
\n
\n\n\n\n\n\n","import { render } from \"./Switch.vue?vue&type=template&id=97d3a936&scoped=true\"\nimport script from \"./Switch.vue?vue&type=script&lang=js\"\nexport * from \"./Switch.vue?vue&type=script&lang=js\"\n\nimport \"./Switch.vue?vue&type=style&index=0&id=97d3a936&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-97d3a936\"]])\n\nexport default __exports__","import Run from './components/Run'\nimport Sensor from \"./components/Sensor\";\nimport Slider from './components/Slider'\nimport Switch from './components/Switch'\n\nexport default {\n Run,\n Sensor,\n Slider,\n Switch,\n}\n","\n \n\n\n\n\n\n","import { render } from \"./Slider.vue?vue&type=template&id=d90e850c&scoped=true\"\nimport script from \"./Slider.vue?vue&type=script&lang=js\"\nexport * from \"./Slider.vue?vue&type=script&lang=js\"\n\nimport \"./Slider.vue?vue&type=style&index=0&id=d90e850c&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-d90e850c\"]])\n\nexport default __exports__","\n
\n \n \n \n
\n\n\n\n\n\n","import { render } from \"./ToggleSwitch.vue?vue&type=template&id=eff375b6&scoped=true\"\nimport script from \"./ToggleSwitch.vue?vue&type=script&lang=js\"\nexport * from \"./ToggleSwitch.vue?vue&type=script&lang=js\"\n\nimport \"./ToggleSwitch.vue?vue&type=style&index=0&id=eff375b6&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-eff375b6\"]])\n\nexport default __exports__","import { render } from \"./Index.vue?vue&type=template&id=450fcab1&scoped=true\"\nimport script from \"./Index.vue?vue&type=script&lang=js\"\nexport * from \"./Index.vue?vue&type=script&lang=js\"\n\nimport \"./Index.vue?vue&type=style&index=0&id=450fcab1&lang=scss&scoped=true\"\n\nimport exportComponent from \"../../../../node_modules/vue-loader/dist/exportHelper.js\"\nconst __exports__ = /*#__PURE__*/exportComponent(script, [['render',render],['__scopeId',\"data-v-450fcab1\"]])\n\nexport default __exports__"],"names":["bus","mitt","name","components","Loading","mixins","Utils","props","content","type","String","data","loading","unwatch","methods","_parseActions","element","actionsTags","children","filter","node","tagName","toLowerCase","length","actionTags","map","actionTag","action","attributes","value","args","reduce","obj","arg","JSON","parse","innerText","e","_parseVars","varsTags","vars","varTag","_parseHandlers","handlers","parseHndlScript","hndlText","app","eval","parseEventHndl","event","hndlTags","mounted","refresh","handler","interval","events","hndlTag","beforeActionsTags","beforeActions","afterActionsTags","afterActions","_parseProps","attr","propagateEvent","emit","_addEventHandler","this","subscribe","_removeEventHandler","$refs","container","innerHTML","Object","entries","forEach","component","$options","getElementsByTagName","actions","_vars","newEl","document","createElement","setAttribute","parentNode","replaceChild","createApp","render","h","mount","removeChild","unmounted","default","iconClass","iconUrl","iconColor","Array","_interval","undefined","refreshInterval","computed","iconStyle","hasIcon","run","input","request_","key","trim","m","match","request","processEvent","hndl","$root","on","self","wrapper","setInterval","clearInterval","class","_createElementBlock","onClick","_cache","_ctx","_hoisted_1","src","alt","_normalizeClass","style","_normalizeStyle","_createElementVNode","_toDisplayString","__exports__","_hoisted_4","_hoisted_5","$props","unit","_hoisted_2","_hoisted_6","_createVNode","_component_SliderElement","range","parseFloat","min","max","onChange","SliderElement","Number","required","target","_component_ToggleSwitch","onInput","_withModifiers","ToggleSwitch","Run","Sensor","Slider","Switch","withRange","withLabel","step","disabled","ref","$event","$emit","emits","Boolean","checked","id","_hoisted_3","_renderSlot","$slots","$data","_createBlock","_component_Loading"],"sourceRoot":""}