((LitElement) => {
const state = {
status: {
key: 'state',
icon: 'mdi:robot-vacuum',
},
fan_speed: {
key: 'fan_speed',
icon: 'mdi:fan',
},
cleaning_mode: {
key: 'cleaning_mode',
icon: 'mdi:speedometer-slow'
},
};
const attributes = {
battery: {
key: 'battery_level',
unit: '%',
icon: 'mdi:battery-charging-80',
},
clean_time: {
key: 'clean_time',
icon: 'mdi:clock-outline',
unit: ' mins'
},
clean_area: {
key: 'clean_area',
icon: 'mdi:grid',
unit: ' m2'
},
};
const buttons = {
start: {
label: 'Start',
icon: 'mdi:play',
service: 'vacuum.start',
},
pause: {
label: 'Pause',
icon: 'mdi:pause',
service: 'vacuum.pause',
},
stop: {
label: 'Stop',
icon: 'mdi:stop',
service: 'vacuum.stop',
},
locate: {
label: 'Locate',
icon: 'mdi:map-marker',
service: 'vacuum.locate',
},
return: {
label: 'Return to Base',
icon: 'mdi:home-map-marker',
service: 'vacuum.return_to_base',
},
};
const html = LitElement.prototype.html;
const css = LitElement.prototype.css;
class TuyaVacuumCard extends LitElement {
static get properties() {
return {
_hass: {},
config: {},
stateObj: {},
isOpen: Boolean,
}
}
constructor() {
super();
this.isOpen = false;
}
static get styles() {
return css`
ha-icon-button ha-icon {
display: flex;
}
.tvac-dropdown{
padding: 0;
display: block;
position: relative;
}
.tvac-dropdown__button{
display: inline-flex;
font-size: 1em;
justify-content: space-between;
align-items: center;
margin: 2px 0;
}
.tvac-dropdown__button.icon{
margin: 0;
}
.tvac-dropdown__button > div {
display: flex;
flex: 1;
justify-content: space-between;
align-items: center;
max-width: 100%;
}
mwc-list-item > *:nth-child(2) {
margin-left: 4px;
}
.tvac-dropdown-open tvac-button ha-icon{
transform: rotate(180deg);
}
.title {
font-size: 20px;
padding: 12px 16px 8px;
text-align: center;
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
}
.flex {
display: flex;
align-items: center;
justify-content: space-evenly;
}
.grid {
display: grid;
grid-template-columns: repeat(2, auto);
cursor: pointer;
}
.grid-content {
display: grid;
align-content: space-between;
grid-row-gap: 6px;
}
.grid-left {
text-align: left;
font-size: 110%;
padding-left: 10px;
border-left: 2px solid var(--primary-color);
}
.grid-right {
text-align: right;
padding-right: 10px;
border-right: 2px solid var(--primary-color);
}
`;
}
firstUpdated() {
const fan_speed_menu = this.shadowRoot.querySelector('#fan_speed-menu');
const fan_speed_button = this.shadowRoot.querySelector('#fan_speed-button');
const cleaning_mode_menu = this.shadowRoot.querySelector('#cleaning_mode-menu');
const cleaning_mode_button = this.shadowRoot.querySelector('#cleaning_mode-button');
fan_speed_menu.anchor = fan_speed_button;
cleaning_mode_menu.anchor = cleaning_mode_button;
}
render() {
return this.stateObj ? html`