import {
LitElement,
html,
css,
property
} from "https://unpkg.com/lit-element@2.3.1/lit-element.js?module";
class TankerkoenigCard extends LitElement {
static get properties() {
return {
hass: {},
config: {}
};
}
render() {
this.stations.sort((a, b) => {
let key = '';
if(a.diesel) {
key = 'diesel';
} else if(a.e5) {
key = 'e5';
} else if(a.e10) {
key = 'e10';
}
if(this.hass.states[a[key]].state === 'unknown' || this.hass.states[a[key]].state === 'unavailable') {
return 1;
}
if(this.hass.states[b[key]].state === 'unknown' || this.hass.states[b[key]].state === 'unavailable') {
return -1;
}
if(this.hass.states[a[key]].state > this.hass.states[b[key]].state) return 1;
if(this.hass.states[b[key]].state > this.hass.states[a[key]].state) return -1;
return 0;
});
let header = '';
if(this.show_header === true) {
header = this.config.name || 'Tankerkönig';
}
return html`
${this.stations.map((station) => {
if(!this.isOpen(station) && this.config.show_closed !== true) return;
return html`
`;
})}
${station.name}
${this.renderPrice(station, 'e5')}
${this.renderPrice(station, 'e10')}
${this.renderPrice(station, 'diesel')}