Fix shade for HVAC action on graph (#3380)

This commit is contained in:
Paulus Schoutsen 2019-07-18 14:03:04 -07:00 committed by GitHub
parent 4f2b82d787
commit cdfd9cea5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 5 deletions

View File

@ -155,6 +155,15 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
domain === "climate" ||
domain === "water_heater"
) {
const isHeating =
domain === "climate"
? (state) => state.attributes.hvac_action === "heating"
: (state) => state.state === "heat";
const isCooling =
domain === "climate"
? (state) => state.attributes.hvac_action === "cooling"
: (state) => state.state === "cool";
// We differentiate between thermostats that have a target temperature
// range versus ones that have just a target temperature
@ -165,8 +174,8 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
state.attributes.target_temp_high !==
state.attributes.target_temp_low
);
const hasHeat = states.states.some((state) => state.state === "heat");
const hasCool = states.states.some((state) => state.state === "cool");
const hasHeat = states.states.some(isHeating);
const hasCool = states.states.some(isCooling);
addColumn(name + " current temperature", true);
if (hasHeat) {
@ -192,10 +201,10 @@ class StateHistoryChartLine extends LocalizeMixin(PolymerElement) {
const curTemp = safeParseFloat(state.attributes.current_temperature);
const series = [curTemp];
if (hasHeat) {
series.push(state.state === "heat" ? curTemp : null);
series.push(isHeating(state) ? curTemp : null);
}
if (hasCool) {
series.push(state.state === "cool" ? curTemp : null);
series.push(isCooling(state) ? curTemp : null);
}
if (hasTargetRange) {
const targetHigh = safeParseFloat(

View File

@ -12,7 +12,7 @@ export type HvacMode =
| "dry"
| "fan_only";
export type HvacAction = "off" | "Heating" | "cooling" | "drying" | "idle";
export type HvacAction = "off" | "heating" | "cooling" | "drying" | "idle";
export type ClimateEntity = HassEntityBase & {
attributes: HassEntityAttributeBase & {