Skip to content

Commit

Permalink
Fix shade for HVAC action on graph (home-assistant#3380)
Browse files Browse the repository at this point in the history
  • Loading branch information
balloob authored Jul 18, 2019
1 parent 4f2b82d commit cdfd9ce
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
17 changes: 13 additions & 4 deletions src/components/state-history-chart-line.js
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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) {
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion src/data/climate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 & {
Expand Down

0 comments on commit cdfd9ce

Please sign in to comment.