Skip to content

Commit

Permalink
Added more min/max properties
Browse files Browse the repository at this point in the history
  • Loading branch information
docbobo committed Aug 27, 2020
1 parent effa84f commit 2644e9c
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions miflora-card.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,13 @@ class MifloraCard extends HTMLElement {
set hass(hass) {
const config = this.config;

var _maxIntensity = config.max_intensity;
var _minIntensity = config.min_intensity;
var _maxMoisture = config.max_moisture;
var _minMoisture = config.min_moisture;
var _maxConductivity = config.max_conductivity;
var _minConductivity = config.min_conductivity;
var _maxTemperature = config.max_termperature;
var _minTemperature = config.min_termperature;

this.shadowRoot.getElementById('container').innerHTML = `
Expand All @@ -76,6 +80,15 @@ class MifloraCard extends HTMLElement {
var _name = config.entities[i].name ? config.entities[i].name : _type;
var _alertStyle = '';
var _alertIcon = '';
if (_type == 'intensity') {
if (_state > _maxIntensity) {
_alertStyle = ';color:red';
_alertIcon = '▲ ';
} else if (_state < _minIntensity) {
_alertStyle = ';color:red';
_alertIcon = '&#9660; ';
}
}
if (_type == 'moisture') {
if (_state > _maxMoisture) {
_alertStyle = ';color:red';
Expand All @@ -86,13 +99,19 @@ class MifloraCard extends HTMLElement {
}
}
if (_type == 'conductivity') {
if (_state < _minConductivity) {
if (_state > _maxConductivity) {
_alertStyle = ';color:red';
_alertIcon = '&#9650; ';
} else if (_state < _minConductivity) {
_alertStyle = ';color:red';
_alertIcon = '&#9660; ';
}
}
if (_type == 'termperature') {
if (_state < _minTemperature) {
if (_type == 'temperature') {
if (_state > _maxTemperature) {
_alertStyle = ';color:red';
_alertIcon = '&#9650; ';
} else if (_state < _minTemperature) {
_alertStyle = ';color:red';
_alertIcon = '&#9660; ';
}
Expand Down

0 comments on commit 2644e9c

Please sign in to comment.