Skip to content

Commit

Permalink
1.7.0
Browse files Browse the repository at this point in the history
*Updated severity to now accept text as well as numerical values.
  • Loading branch information
Gluwc committed Feb 2, 2020
1 parent a4f97b7 commit 31a84d8
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions bar-card.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
console.info(
`%cBAR-CARD\n%cVersion: 1.7.0`,
"color: green; font-weight: bold;",
""
);

class BarCard extends HTMLElement {
constructor () {
super()
Expand Down Expand Up @@ -696,6 +702,11 @@ class BarCard extends HTMLElement {
let color
sections.forEach(section => {
let actualValue = this._valueEntityCheck(section.value, hass)
if (isNaN(actualValue)) {
if (actualValue == stateValue && !color) {
color = section.color
}
}
if (numberValue <= actualValue && !color) {
color = section.color
}
Expand All @@ -709,6 +720,11 @@ class BarCard extends HTMLElement {
let icon
sections.forEach(section => {
let actualValue = this._valueEntityCheck(section.value, hass)
if (isNaN(actualValue)) {
if (actualValue == stateValue && !icon) {
icon = section.icon
}
}
if (numberValue <= actualValue && !icon) {
icon = section.icon
}
Expand All @@ -730,7 +746,7 @@ class BarCard extends HTMLElement {
return attribute
}
} else {
if (this._hass.states[value] == undefined) throw new Error('Invalid target, min or max entity')
if (this._hass.states[value] == undefined) return value
else return hass.states[value].state
}
} else {
Expand Down Expand Up @@ -1223,10 +1239,4 @@ class BarCard extends HTMLElement {
}
}

customElements.define('bar-card', BarCard)

console.info(
`%cBAR-CARD\n%cVersion: 1.6.2`,
"color: green; font-weight: bold;",
""
);
customElements.define('bar-card', BarCard)

0 comments on commit 31a84d8

Please sign in to comment.