Green shade in climate history for platforms that don't support hvac_action (#3787)

* Green shade in climate history for platforms that don't support HVAC_ACTION

* The presence of hvac_action can change over time

* Move static condition out of anon function
This commit is contained in:
On Freund 2019-09-24 11:34:13 +03:00 committed by Bram Kragten
parent c59b6626f2
commit 38b817bd67

View File

@ -155,15 +155,21 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
domain === "climate" ||
domain === "water_heater"
) {
const hasHvacAction = states.states.some(
(state) => state.attributes && state.attributes.hvac_action
);
const isHeating =
domain === "climate"
domain === "climate" && hasHvacAction
? (state) => state.attributes.hvac_action === "heating"
: (state) => state.state === "heat";
const isCooling =
domain === "climate"
domain === "climate" && hasHvacAction
? (state) => state.attributes.hvac_action === "cooling"
: (state) => state.state === "cool";
const hasHeat = states.states.some(isHeating);
const hasCool = states.states.some(isCooling);
// We differentiate between thermostats that have a target temperature
// range versus ones that have just a target temperature
@ -174,8 +180,6 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
state.attributes.target_temp_high !==
state.attributes.target_temp_low
);
const hasHeat = states.states.some(isHeating);
const hasCool = states.states.some(isCooling);
addColumn(name + " current temperature", true);
if (hasHeat) {