iobroker.lovelace
Version:
With this adapter you can build visualization for ioBroker with Home Assistant Lovelace UI
1 lines • 3.03 kB
JavaScript
export const __rspack_esm_id=4619;export const __rspack_esm_ids=[4619];export const __webpack_modules__={37446(e,t,o){o.a(e,async function(e,a){try{o.r(t),o.d(t,{HuiPrecipitationForecastCardFeatureEditor:()=>u});o(74423);var i=o(62826),s=o(5124),r=o(22441),c=o(22786),l=o(1087),n=o(52763),p=o(43248),_=o(70565),h=e([n]);n=(h.then?(await h)():h)[0];class u extends s.WF{setConfig(e){this._config=e}render(){if(!this.hass||!this._config)return s.s6;const e=this.context?.entity_id?this.hass.states[this.context.entity_id]:void 0,t=(0,_.Sg)(e,this._config.forecast_type)||"daily",o="hourly"===t,a={...this._config,forecast_type:t,precipitation_type:this._config.precipitation_type??"amount",...o?{hours_to_show:this._config.hours_to_show??24}:{days_to_show:this._config.days_to_show??7}},i=this._schema(e,t,this.hass.localize);return s.qy` <ha-form .hass="${this.hass}" .data="${a}" .schema="${i}" .computeLabel="${this._computeLabelCallback}" -changed="${this._valueChanged}"></ha-form> `}_valueChanged(e){(0,l.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})],u.prototype,"hass",void 0),(0,i.Cg)([(0,r.MZ)({attribute:!1})],u.prototype,"context",void 0),(0,i.Cg)([(0,r.wk)()],u.prototype,"_config",void 0),u=(0,i.Cg)([(0,r.EM)("hui-precipitation-forecast-card-feature-editor")],u),a()}catch(e){a(e)}})}};