Skip to content

Commit

Permalink
Fix displaying card when sensor not available
Browse files Browse the repository at this point in the history
  • Loading branch information
MrBartusek committed May 20, 2021
1 parent 75e0128 commit f441782
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions src/meteoalarm-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,13 @@ class MeteoalarmCard extends LitElement
awareness_level: awarenessLevel,
} = entity.attributes;

const entityState = (status || state || entity.state)

let result = {
isWarningActive: (status || state || entity.state) != 'off'
isAvailable: entityState != 'unavailable',
isWarningActive: entityState == 'on'
};
console.log(result)

if(result.isWarningActive)
{
Expand Down Expand Up @@ -147,7 +151,7 @@ class MeteoalarmCard extends LitElement
renderIcon()
{
let iconName = ''
if(!this.entity)
if(!this.entity || !this.getAttributes(this.entity).isAvailable)
{
iconName = 'cloud-question'
}
Expand Down Expand Up @@ -216,7 +220,7 @@ class MeteoalarmCard extends LitElement
{
try
{
if(!this.entity)
if(!this.entity || !this.getAttributes(this.entity).isAvailable)
{
return this.renderNotAvailable()
}
Expand Down

0 comments on commit f441782

Please sign in to comment.