UNPKG

iobroker.lovelace

Version:

With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI

2 lines 6.14 kB
export const __webpack_ids__=["34277"];export const __webpack_modules__={39746:function(e,t,a){a.r(t),a.d(t,{HuiWeatherForecastCardEditor:()=>p});var o=a(44249),s=(a(9359),a(70104),a(57243)),r=a(15093),c=a(27486),i=a(62900),l=a(36522),n=a(75278),h=(a(29073),a(96194)),_=a(49319),u=a(30571),d=a(18200);const f=(0,i.f0)(d.I,(0,i.Ry)({entity:(0,i.jt)((0,i.Z_)()),name:(0,i.jt)((0,i.Z_)()),theme:(0,i.jt)((0,i.Z_)()),show_current:(0,i.jt)((0,i.O7)()),show_forecast:(0,i.jt)((0,i.O7)()),forecast_type:(0,i.jt)((0,i.Z_)()),forecast_slots:(0,i.jt)((0,i.Rx)()),secondary_info_attribute:(0,i.jt)((0,i.Z_)()),tap_action:(0,i.jt)(u.fJ),hold_action:(0,i.jt)(u.fJ),double_tap_action:(0,i.jt)(u.fJ)}));let p=(0,o.Z)([(0,r.Mo)("hui-weather-forecast-card-editor")],(function(e,t){return{F:class extends t{constructor(...t){super(...t),e(this)}},d:[{kind:"field",decorators:[(0,r.Cb)({attribute:!1})],key:"hass",value:void 0},{kind:"field",decorators:[(0,r.SB)()],key:"_config",value:void 0},{kind:"method",key:"setConfig",value:function(e){if((0,i.hu)(e,f),this._config=e,(!0===e.show_forecast&&!1===this._hasForecast||!1===e.show_current&&!1===e.show_forecast)&&(0,l.B)(this,"config-changed",{config:{...e,show_current:!0,show_forecast:!1}}),!e.forecast_type||"legacy"===e.forecast_type&&this._modernForecastSupported()||!this._forecastSupported(e.forecast_type)){let t;this._forecastSupported("daily")?t="daily":this._forecastSupported("hourly")?t="hourly":this._forecastSupported("twice_daily")?t="twice_daily":this._forecastSupported("legacy")&&(t="legacy"),(0,l.B)(this,"config-changed",{config:{...e,forecast_type:t}})}}},{kind:"get",key:"_stateObj",value:function(){if(this.hass&&this._config)return this.hass.states[this._config.entity]}},{kind:"get",key:"_hasForecast",value:function(){const e=this._stateObj;if(e&&e.state!==h.nZ)return!(!e.attributes.forecast?.length&&!e.attributes.supported_features)}},{kind:"method",key:"_forecastSupported",value:function(e){const t=this._stateObj;return"legacy"===e?!!t.attributes.forecast?.length:"daily"===e?(0,n.e)(t,_.yF.FORECAST_DAILY):"hourly"===e?(0,n.e)(t,_.yF.FORECAST_HOURLY):"twice_daily"===e&&(0,n.e)(t,_.yF.FORECAST_TWICE_DAILY)}},{kind:"method",key:"_modernForecastSupported",value:function(){return this._forecastSupported("daily")||this._forecastSupported("hourly")||this._forecastSupported("twice_daily")}},{kind:"field",key:"_schema",value:()=>(0,c.Z)(((e,t,a,o,s)=>[{name:"entity",required:!0,selector:{entity:{domain:"weather"}}},{name:"name",selector:{text:{}}},{name:"",type:"grid",schema:[{name:"secondary_info_attribute",selector:{attribute:{}},context:{filter_entity:"entity"}},{name:"theme",selector:{theme:{}}}]},...a||o||s?[{name:"forecast_type",selector:{select:{options:[...a?[{value:"daily",label:e("ui.panel.lovelace.editor.card.weather-forecast.daily")}]:[],...o?[{value:"hourly",label:e("ui.panel.lovelace.editor.card.weather-forecast.hourly")}]:[],...s?[{value:"twice_daily",label:e("ui.panel.lovelace.editor.card.weather-forecast.twice_daily")}]:[]]}}}]:[],...a||o||s||t?[{name:"forecast",selector:{select:{options:[{value:"show_both",label:e("ui.panel.lovelace.editor.card.weather-forecast.show_both")},{value:"show_current",label:e("ui.panel.lovelace.editor.card.weather-forecast.show_only_current")},{value:"show_forecast",label:e("ui.panel.lovelace.editor.card.weather-forecast.show_only_forecast")}]}}},{name:"forecast_slots",selector:{number:{min:1,max:12}},default:5},{name:"interactions",type:"expandable",flatten:!0,iconPath:"M10,9A1,1 0 0,1 11,8A1,1 0 0,1 12,9V13.47L13.21,13.6L18.15,15.79C18.68,16.03 19,16.56 19,17.14V21.5C18.97,22.32 18.32,22.97 17.5,23H11C10.62,23 10.26,22.85 10,22.57L5.1,18.37L5.84,17.6C6.03,17.39 6.3,17.28 6.58,17.28H6.8L10,19V9M11,5A4,4 0 0,1 15,9C15,10.5 14.2,11.77 13,12.46V11.24C13.61,10.69 14,9.89 14,9A3,3 0 0,0 11,6A3,3 0 0,0 8,9C8,9.89 8.39,10.69 9,11.24V12.46C7.8,11.77 7,10.5 7,9A4,4 0 0,1 11,5Z",schema:[{name:"tap_action",selector:{ui_action:{default_action:"more-info"}}},{name:"",type:"optional_actions",flatten:!0,schema:["hold_action","double_tap_action"].map((e=>({name:e,selector:{ui_action:{default_action:"none"}}})))}]}]:[]]))},{kind:"method",key:"render",value:function(){if(!this.hass||!this._config)return s.Ld;const e=this._schema(this.hass.localize,this._forecastSupported("legacy"),this._forecastSupported("daily"),this._forecastSupported("hourly"),this._forecastSupported("twice_daily")),t={show_current:!0,show_forecast:this._hasForecast,...this._config};return t.forecast=t.show_current&&t.show_forecast?"show_both":t.show_current?"show_current":"show_forecast",s.dy` <ha-form .hass="${this.hass}" .data="${t}" .schema="${e}" .computeLabel="${this._computeLabelCallback}" @value-changed="${this._valueChanged}"></ha-form> `}},{kind:"method",key:"_valueChanged",value:function(e){const t=e.detail.value;"show_both"===t.forecast?(t.show_current=!0,t.show_forecast=!0):"show_current"===t.forecast?(t.show_current=!0,t.show_forecast=!1):(t.show_current=!1,t.show_forecast=!0),delete t.forecast,(0,l.B)(this,"config-changed",{config:t})}},{kind:"field",key:"_computeLabelCallback",value(){return e=>{switch(e.name){case"entity":return`${this.hass.localize("ui.panel.lovelace.editor.card.generic.entity")} (${this.hass.localize("ui.panel.lovelace.editor.card.config.required")})`;case"theme":return`${this.hass.localize("ui.panel.lovelace.editor.card.generic.theme")} (${this.hass.localize("ui.panel.lovelace.editor.card.config.optional")})`;case"forecast_type":return this.hass.localize("ui.panel.lovelace.editor.card.weather-forecast.forecast_type");case"forecast_slots":return this.hass.localize("ui.panel.lovelace.editor.card.weather-forecast.forecast_slots");case"forecast":return this.hass.localize("ui.panel.lovelace.editor.card.weather-forecast.weather_to_show");default:return this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`)}}}}]}}),s.oi)},18200:function(e,t,a){a.d(t,{I:()=>s});var o=a(62900);const s=(0,o.Ry)({type:(0,o.Z_)(),view_layout:(0,o.Yj)(),layout_options:(0,o.Yj)(),grid_options:(0,o.Yj)(),visibility:(0,o.Yj)()})}}; //# sourceMappingURL=34277.f538bb601ff93892.js.map