Skip to content

Commit

Permalink
Merge pull request #48 from ikaruswill/insajd-unavailable_improvements
Browse files Browse the repository at this point in the history
Better unnamed & unavailable entity parsing
  • Loading branch information
insajd authored Apr 29, 2021
2 parents d12514c + c944c0b commit 61d472e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions fan-xiaomi.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,20 @@ class FanXiaomi extends HTMLElement {
card.appendChild(ui)

// Check if fan is disconnected
if(state === undefined){
if(state === undefined || state.state === 'unavailable'){
card.classList.add('offline');
this.card = card;
this.appendChild(card);
ui.querySelector('.var-title').textContent = this.config.name + ' (Disconnected)';
ui.querySelector('.var-title').textContent = (this.config.name || '') + ' (Disconnected)';
return;
}
}


if (state.state === 'unavailable'){
ui.querySelector('.var-title').textContent = (this.config.name || '') + ' (Disconnected)';
return;
}

const attrs = state.attributes;

if (attrs['model'] === 'dmaker.fan.1c'){
Expand Down

0 comments on commit 61d472e

Please sign in to comment.