c.1067c64a.js 6.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. import{_ as e,j as i,e as t,y as s,J as d,d as a,n as c,t as l,a5 as r,E as o,G as n}from"./main-ec7846c8.js";import{g as v,d as u}from"./c.84dcc549.js";import{f as h,b as k}from"./c.6f18200a.js";import{S as p}from"./c.79c8c092.js";import"./c.980b1140.js";import"./c.6eb9fcd4.js";import"./c.1024e243.js";import"./c.0e3055bd.js";import"./c.8e28b461.js";import"./c.eea05cf6.js";import"./c.874c8cfd.js";import"./c.fa0ef026.js";import"./c.d2f13ac1.js";import"./c.227858d9.js";e([c("ha-devices-picker")],(function(e,i){return{F:class extends i{constructor(...i){super(...i),e(this)}},d:[{kind:"field",decorators:[t({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[t()],key:"value",value:void 0},{kind:"field",decorators:[t()],key:"helper",value:void 0},{kind:"field",decorators:[t({type:Boolean})],key:"disabled",value:void 0},{kind:"field",decorators:[t({type:Boolean})],key:"required",value:void 0},{kind:"field",decorators:[t({type:Array,attribute:"include-domains"})],key:"includeDomains",value:void 0},{kind:"field",decorators:[t({type:Array,attribute:"exclude-domains"})],key:"excludeDomains",value:void 0},{kind:"field",decorators:[t({attribute:"picked-device-label"}),t({type:Array,attribute:"include-device-classes"})],key:"includeDeviceClasses",value:void 0},{kind:"field",key:"pickedDeviceLabel",value:void 0},{kind:"field",decorators:[t({attribute:"pick-device-label"})],key:"pickDeviceLabel",value:void 0},{kind:"field",decorators:[t()],key:"deviceFilter",value:void 0},{kind:"method",key:"render",value:function(){if(!this.hass)return s``;const e=this._currentDevices;return s`
  2. ${e.map((e=>s`
  3. <div>
  4. <ha-device-picker
  5. allow-custom-entity
  6. .curValue=${e}
  7. .hass=${this.hass}
  8. .deviceFilter=${this.deviceFilter}
  9. .includeDomains=${this.includeDomains}
  10. .excludeDomains=${this.excludeDomains}
  11. .includeDeviceClasses=${this.includeDeviceClasses}
  12. .value=${e}
  13. .label=${this.pickedDeviceLabel}
  14. .disabled=${this.disabled}
  15. @value-changed=${this._deviceChanged}
  16. ></ha-device-picker>
  17. </div>
  18. `))}
  19. <div>
  20. <ha-device-picker
  21. allow-custom-entity
  22. .hass=${this.hass}
  23. .helper=${this.helper}
  24. .deviceFilter=${this.deviceFilter}
  25. .includeDomains=${this.includeDomains}
  26. .excludeDomains=${this.excludeDomains}
  27. .includeDeviceClasses=${this.includeDeviceClasses}
  28. .label=${this.pickDeviceLabel}
  29. .disabled=${this.disabled}
  30. .required=${this.required&&!e.length}
  31. @value-changed=${this._addDevice}
  32. ></ha-device-picker>
  33. </div>
  34. `}},{kind:"get",key:"_currentDevices",value:function(){return this.value||[]}},{kind:"method",key:"_updateDevices",value:async function(e){d(this,"value-changed",{value:e}),this.value=e}},{kind:"method",key:"_deviceChanged",value:function(e){e.stopPropagation();const i=e.currentTarget.curValue,t=e.detail.value;t!==i&&""===t&&(""===t?this._updateDevices(this._currentDevices.filter((e=>e!==i))):this._updateDevices(this._currentDevices.map((e=>e===i?t:e))))}},{kind:"method",key:"_addDevice",value:async function(e){e.stopPropagation();const i=e.detail.value;if(e.currentTarget.value="",!i)return;const t=this._currentDevices;t.includes(i)||this._updateDevices([...t,i])}},{kind:"field",static:!0,key:"styles",value:()=>a`
  35. div {
  36. margin-top: 8px;
  37. }
  38. `}]}}),i);let y=e([c("ha-selector-device")],(function(e,i){class d extends i{constructor(...i){super(...i),e(this)}}return{F:d,d:[{kind:"field",decorators:[t()],key:"hass",value:void 0},{kind:"field",decorators:[t()],key:"selector",value:void 0},{kind:"field",decorators:[l()],key:"_entitySources",value:void 0},{kind:"field",decorators:[l()],key:"_entities",value:void 0},{kind:"field",decorators:[t()],key:"value",value:void 0},{kind:"field",decorators:[t()],key:"label",value:void 0},{kind:"field",decorators:[t()],key:"helper",value:void 0},{kind:"field",decorators:[t({type:Boolean})],key:"disabled",value:()=>!1},{kind:"field",decorators:[t({type:Boolean})],key:"required",value:()=>!0},{kind:"field",key:"_deviceIntegrationLookup",value:()=>r(v)},{kind:"method",key:"hassSubscribe",value:function(){return[u(this.hass.connection,(e=>{this._entities=e.filter((e=>null!==e.device_id))}))]}},{kind:"method",key:"updated",value:function(e){o(n(d.prototype),"updated",this).call(this,e),e.has("selector")&&this.selector.device.integration&&!this._entitySources&&h(this.hass).then((e=>{this._entitySources=e}))}},{kind:"method",key:"render",value:function(){var e,i,t,d;return this.selector.device.integration&&!this._entitySources?s``:this.selector.device.multiple?s`
  39. ${this.label?s`<label>${this.label}</label>`:""}
  40. <ha-devices-picker
  41. .hass=${this.hass}
  42. .value=${this.value}
  43. .helper=${this.helper}
  44. .deviceFilter=${this._filterDevices}
  45. .includeDeviceClasses=${null!==(e=this.selector.device.entity)&&void 0!==e&&e.device_class?[this.selector.device.entity.device_class]:void 0}
  46. .includeDomains=${null!==(i=this.selector.device.entity)&&void 0!==i&&i.domain?[this.selector.device.entity.domain]:void 0}
  47. .disabled=${this.disabled}
  48. .required=${this.required}
  49. ></ha-devices-picker>
  50. `:s`
  51. <ha-device-picker
  52. .hass=${this.hass}
  53. .value=${this.value}
  54. .label=${this.label}
  55. .helper=${this.helper}
  56. .deviceFilter=${this._filterDevices}
  57. .includeDeviceClasses=${null!==(t=this.selector.device.entity)&&void 0!==t&&t.device_class?[this.selector.device.entity.device_class]:void 0}
  58. .includeDomains=${null!==(d=this.selector.device.entity)&&void 0!==d&&d.domain?[this.selector.device.entity.domain]:void 0}
  59. .disabled=${this.disabled}
  60. .required=${this.required}
  61. allow-custom-entity
  62. ></ha-device-picker>
  63. `}},{kind:"field",key:"_filterDevices",value(){return e=>{const i=this._entitySources&&this._entities?this._deviceIntegrationLookup(this._entitySources,this._entities):void 0;return k(this.selector.device,e,i)}}}]}}),p(i));export{y as HaDeviceSelector};