platypush/platypush/backend/http/webapp/dist/static/js/3674-legacy.c0844108.js

2 lines
9.4 KiB
JavaScript

"use strict";(self["webpackChunkplatypush"]=self["webpackChunkplatypush"]||[]).push([[3674],{3674:function(e,t,n){n.r(t),n.d(t,{default:function(){return L}});var r=n(6252);function i(e,t,n,i,u,s){var o=(0,r.up)("Loading"),a=(0,r.up)("LightPlugin");return(0,r.wg)(),(0,r.iD)(r.HY,null,[u.loading?((0,r.wg)(),(0,r.j4)(o,{key:0})):(0,r.kq)("",!0),(0,r.Wm)(a,{"plugin-name":"light.hue",config:n.config,lights:e.lights,groups:e.groups,scenes:e.scenes,animations:e.animations,"initial-group":s.initialGroup,"loading-groups":e.loadingGroups,"color-converter":u.colorConverter,onGroupToggle:s.toggleGroup,onLightChanged:s.onLightChanged,onLightToggle:s.toggleLight,onSetLight:s.setLight,onSetGroup:s.setGroup,onSelectScene:s.setScene,onStartAnimation:s.startAnimation,onStopAnimation:s.stopAnimation,onRefresh:t[0]||(t[0]=function(e){return s.refresh(!0)})},null,8,["config","lights","groups","scenes","animations","initial-group","loading-groups","color-converter","onGroupToggle","onLightChanged","onLightToggle","onSetLight","onSetGroup","onSelectScene","onStartAnimation","onStopAnimation"])],64)}var u=n(4648),s=n(9584),o=n(6084),a=n(8534),c=(n(5666),n(7941),n(1539),n(7327),n(9720),n(3948),n(2479),n(1249),n(8309),n(2222),n(8783),n(1406)),g=(n(4747),{name:"Utils",data:function(){return{lights:{},groups:{},scenes:{},animations:{},loadingLights:{},loadingGroups:{}}},computed:{groupsByName:function(){return this.groups?Object.entries(this.groups).reduce((function(e,t){var n=(0,o.Z)(t,2),r=n[0],i=n[1];return e[i.name||r]=(0,u.Z)((0,u.Z)({},i),{},{id:r}),e}),{}):{}}},methods:{_getGroups:function(e){var t=e.filter((function(e){return null!=e}));if(!t.length)return Object.values(this.groups);var n=this;return t.map((function(e){return e instanceof Object?e:n.groups[e]}))},_getLights:function(e){var t=e.filter((function(e){return null!=e}));if(!t.length)return Object.values(this.lights);var n=this;return t.map((function(e){return e instanceof Object?e:n.lights[e]}))},setGroupsLoading:function(e){var t=this;this._getGroups(e).forEach((function(e){t.loadingGroups[e.id]=!0,e.lights&&t.setLightsLoading(e.lights)}))},unsetGroupsLoading:function(e){var t=this;this._getGroups(e).forEach((function(e){e.id in t.loadingGroups&&delete t.loadingGroups[e.id],e.lights&&t.setLightsLoading(e.lights)}))},setLightsLoading:function(e){var t=this;this._getLights(e).forEach((function(e){t.loadingLights[e.id]=!0}))},unsetLightsLoading:function(e){var t=this;this._getLights(e).forEach((function(e){e.id in t.loadingLights&&delete t.loadingLights[e.id]}))},groupAction:function(e,t){var n=arguments,r=this;return(0,a.Z)(regeneratorRuntime.mark((function i(){var u,s,o;return regeneratorRuntime.wrap((function(i){while(1)switch(i.prev=i.next){case 0:for(u=n.length,s=new Array(u>2?u-2:0),o=2;o<u;o++)s[o-2]=n[o];return r.setGroupsLoading(s),i.prev=2,i.next=5,r.request(e,t);case 5:return i.abrupt("return",i.sent);case 6:return i.prev=6,r.unsetGroupsLoading(s),i.finish(6);case 9:case"end":return i.stop()}}),i,null,[[2,,6,9]])})))()},lightAction:function(e,t){var n=arguments,r=this;return(0,a.Z)(regeneratorRuntime.mark((function i(){var u,s,o;return regeneratorRuntime.wrap((function(i){while(1)switch(i.prev=i.next){case 0:for(u=n.length,s=new Array(u>2?u-2:0),o=2;o<u;o++)s[o-2]=n[o];return r.setLightsLoading(s),i.prev=2,i.next=5,r.request(e,t);case 5:return i.abrupt("return",i.sent);case 6:return i.prev=6,r.unsetLightsLoading(s),i.finish(6);case 9:case"end":return i.stop()}}),i,null,[[2,,6,9]])})))()}}});const h=g;var l=h,p=n(634),f=n(2628),m=n(1232),d={name:"LightHue",components:{Loading:m.Z,LightPlugin:c["default"]},mixins:[f.Z,l],props:{config:{type:Object,default:function(){}}},data:function(){return{loading:!1,colorConverter:new p.N({hue:[0,65535],sat:[0,255],bri:[0,255],ct:[150,500]})}},computed:{initialGroup:function(){if(!this.config.groups||!Object.keys(this.config.groups).length)return null;var e=this.config.groups[0];return e in this.groups?this.groups[e].id:e in this.groupsByName?this.groupsByName[e].id:null}},methods:{getLights:function(){var e=this;return(0,a.Z)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.request("light.hue.get_lights");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))()},getGroups:function(){var e=this;return(0,a.Z)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.t0=Object,t.next=3,e.request("light.hue.get_groups");case 3:return t.t1=t.sent,t.abrupt("return",t.t0.entries.call(t.t0,t.t1).filter((function(e){return!e[1].recycle&&"room"===e[1].type.toLowerCase()})).reduce((function(e,t){var n=(0,o.Z)(t,2),r=n[0],i=n[1];return e[r]=i,e}),{}));case 5:case"end":return t.stop()}}),t)})))()},getScenes:function(){var e=this;return(0,a.Z)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.t0=Object,t.next=3,e.request("light.hue.get_scenes");case 3:return t.t1=t.sent,t.abrupt("return",t.t0.entries.call(t.t0,t.t1).filter((function(e){return!e[1].recycle&&"lightscene"===e[1].type.toLowerCase()})).reduce((function(e,t){var n=(0,o.Z)(t,2),r=n[0],i=n[1];return e[r]=i,e}),{}));case 5:case"end":return t.stop()}}),t)})))()},getAnimations:function(){var e=this;return(0,a.Z)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.request("light.hue.get_animations");case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t)})))()},toggleGroup:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return r=Object.values(t.groups),i={groups:r.map((function(e){return e.name}))},null!=e&&(r=[e],i={groups:[e.name]}),n.next=5,t.groupAction.apply(t,["light.hue.toggle",i].concat((0,s.Z)(r)));case 5:return n.next=7,t.refresh(!0);case 7:case"end":return n.stop()}}),n)})))()},toggleLight:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return r=[e],i=null!=e?{lights:[e.name]}:{},n.next=4,t.lightAction.apply(t,["light.hue.toggle",i].concat(r));case 4:return n.next=6,t.refresh(!0);case 6:case"end":return n.stop()}}),n)})))()},setLight:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){var r,i,u,a,c;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return r=Object.keys(t.lights),i=e.light,u={},i&&(u.lights=[i.name],r=[i]),a=t,c=Object.entries(e.value).map((function(e){var t=(0,o.Z)(e,2),n=t[0],i=t[1],c=null;switch(u.value=i,n){case"brightness":c="light.hue.bri";break;case"temperature":c="light.hue.ct";break;case"xy":c="light.hue.xy";break}if(c)return a.lightAction.apply(a,[c,u].concat((0,s.Z)(r)))})).filter((function(e){return null!=e})),n.next=8,Promise.all(c);case 8:return n.next=10,t.refresh(!0);case 10:case"end":return n.stop()}}),n)})))()},setGroup:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){var r,i,u,s;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:if(e.groupId){n.next=2;break}return n.abrupt("return",t.setLight(e));case 2:return r=t.groups[e.groupId],i={groups:[r.name]},u=t,s=Object.entries(e.value).map((function(e){var t=(0,o.Z)(e,2),n=t[0],s=t[1],a=null;switch(i.value=s,n){case"brightness":a="light.hue.bri";break;case"temperature":a="light.hue.ct";break;case"xy":a="light.hue.xy";break}if(a)return u.groupAction(a,i,r)})).filter((function(e){return null!=e})),n.next=8,Promise.all(s);case 8:return n.next=10,t.refresh(!0);case 10:case"end":return n.stop()}}),n)})))()},setScene:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return n.next=2,t.groupAction("light.hue.scene",{name:t.scenes[e.sceneId].name,groups:[t.groups[e.groupId].name]},t.groups[e.groupId]);case 2:return n.next=4,t.refresh(!0);case 4:case"end":return n.stop()}}),n)})))()},refresh:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){var r,i;return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return e||(t.loading=!0),n.prev=1,n.next=4,Promise.all([t.getLights(),t.getGroups(),t.getScenes(),t.getAnimations()]);case 4:r=n.sent,i=(0,o.Z)(r,4),t.lights=i[0],t.groups=i[1],t.scenes=i[2],t.animations=i[3];case 10:return n.prev=10,e||(t.loading=!1),n.finish(10);case 13:case"end":return n.stop()}}),n,null,[[1,,10,13]])})))()},startAnimation:function(e){var t=this;return(0,a.Z)(regeneratorRuntime.mark((function n(){return regeneratorRuntime.wrap((function(n){while(1)switch(n.prev=n.next){case 0:return n.next=2,t.request("light.hue.animate",(0,u.Z)({lights:e.lights},e.animation));case 2:return n.next=4,t.refresh(!0);case 4:case"end":return n.stop()}}),n)})))()},stopAnimation:function(){var e=this;return(0,a.Z)(regeneratorRuntime.mark((function t(){return regeneratorRuntime.wrap((function(t){while(1)switch(t.prev=t.next){case 0:return t.next=2,e.request("light.hue.stop_animation");case 2:return t.next=4,e.refresh(!0);case 4:case"end":return t.stop()}}),t)})))()},onLightChanged:function(e){this.lights[e.id].state=(0,u.Z)((0,u.Z)({},this.lights[e.id].state),e.state)}},mounted:function(){this.refresh()}},v=n(3744);const w=(0,v.Z)(d,[["render",i]]);var L=w}}]);
//# sourceMappingURL=3674-legacy.c0844108.js.map