iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.25 kB
JavaScript
"use strict";(self.rspackChunkhome_assistant_frontend=self.rspackChunkhome_assistant_frontend||[]).push([[4619],{15065:function(e,t,o){o.a(e,async function(e,a){try{o.r(t),o.d(t,{HuiPrecipitationForecastCardFeatureEditor:function(){return f}});o(74423),o(62953);var i=o(40445),s=o(5124),r=o(67576),c=o(22786),n=o(1087),l=o(52763),p=o(43248),u=o(70565),h=e([l]);l=(h.then?(await h)():h)[0];let d,_=e=>e;class f extends s.WF{setConfig(e){this._config=e}render(){var e,t,o,a;if(!this.hass||!this._config)return s.s6;const i=null!==(e=this.context)&&void 0!==e&&e.entity_id?this.hass.states[this.context.entity_id]:void 0,r=(0,u.Sg)(i,this._config.forecast_type)||"daily",c="hourly"===r,n=Object.assign(Object.assign({},this._config),{},{forecast_type:r,precipitation_type:null!==(t=this._config.precipitation_type)&&void 0!==t?t:"amount"},c?{hours_to_show:null!==(o=this._config.hours_to_show)&&void 0!==o?o:24}:{days_to_show:null!==(a=this._config.days_to_show)&&void 0!==a?a:7}),l=this._schema(i,r,this.hass.localize);return(0,s.qy)(d||(d=_` <ha-form .hass="${0}" .data="${0}" .schema="${0}" .computeLabel="${0}" -changed="${0}"></ha-form> `),this.hass,n,l,this._computeLabelCallback,this._valueChanged)}_valueChanged(e){(0,n.r)(this,"config-changed",{config:e.detail.value})}constructor(...e){super(...e),this._schema=(0,c.A)((e,t,o)=>{const a=e?(0,p.V7)(e):[],i="hourly"===t;return[{name:"forecast_type",required:!0,disabled:a.length<=1,selector:{select:{mode:"dropdown",options:["daily","twice_daily","hourly"].map(e=>({value:e,label:o(`ui.panel.lovelace.editor.features.types.precipitation-forecast.forecast_type_options.${e}`),disabled:!a.includes(e)}))}}},i?{name:"hours_to_show",default:24,selector:{number:{min:1,mode:"box"}}}:{name:"days_to_show",default:7,selector:{number:{min:1,mode:"box"}}},{name:"precipitation_type",required:!0,selector:{select:{mode:"dropdown",options:[{value:"amount",label:o("ui.panel.lovelace.editor.features.types.precipitation-forecast.precipitation_type_options.amount")},{value:"probability",label:o("ui.panel.lovelace.editor.features.types.precipitation-forecast.precipitation_type_options.probability")}]}}},{name:"color",selector:{ui_color:{default_color:"state",include_state:!0}}},{name:"show_labels",default:!0,selector:{boolean:{}}}]}),this._computeLabelCallback=e=>{switch(e.name){case"forecast_type":return this.hass.localize("ui.panel.lovelace.editor.features.types.precipitation-forecast.forecast_type");case"days_to_show":case"hours_to_show":return this.hass.localize(`ui.panel.lovelace.editor.card.generic.${e.name}`);case"precipitation_type":return this.hass.localize("ui.panel.lovelace.editor.features.types.precipitation-forecast.precipitation_type");case"color":return this.hass.localize("ui.panel.lovelace.editor.features.types.precipitation-forecast.color");case"show_labels":return this.hass.localize("ui.panel.lovelace.editor.features.types.precipitation-forecast.show_labels");default:return""}}}}(0,i.Cg)([(0,r.MZ)({attribute:!1})],f.prototype,"hass",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],f.prototype,"context",void 0),(0,i.Cg)([(0,r.wk)()],f.prototype,"_config",void 0),f=(0,i.Cg)([(0,r.EM)("hui-precipitation-forecast-card-feature-editor")],f),a()}catch(d){a(d)}})}}]);