mirror of
https://github.com/home-assistant/frontend.git
synced 2026-04-18 07:56:44 +01:00
Support additional climate hvac_mode in state-history-chart-line (#30310)
* Support additional climate hvac_mode in state-history-chart-line * Reverted changes to the chart legend to keep change focussed on the additonal hvac_mode support * Remove the tests since they don't add value.
This commit is contained in:
@@ -443,9 +443,25 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
entityState.attributes?.hvac_action
|
entityState.attributes?.hvac_action
|
||||||
] === "cool"
|
] === "cool"
|
||||||
: (entityState: LineChartState) => entityState.state === "cool";
|
: (entityState: LineChartState) => entityState.state === "cool";
|
||||||
|
const isDrying =
|
||||||
|
domain === "climate" && hasHvacAction
|
||||||
|
? (entityState: LineChartState) =>
|
||||||
|
CLIMATE_HVAC_ACTION_TO_MODE[
|
||||||
|
entityState.attributes?.hvac_action
|
||||||
|
] === "dry"
|
||||||
|
: (entityState: LineChartState) => entityState.state === "dry";
|
||||||
|
const isFanOnly =
|
||||||
|
domain === "climate" && hasHvacAction
|
||||||
|
? (entityState: LineChartState) =>
|
||||||
|
CLIMATE_HVAC_ACTION_TO_MODE[
|
||||||
|
entityState.attributes?.hvac_action
|
||||||
|
] === "fan_only"
|
||||||
|
: (entityState: LineChartState) => entityState.state === "fan_only";
|
||||||
|
|
||||||
const hasHeat = states.states.some(isHeating);
|
const hasHeat = states.states.some(isHeating);
|
||||||
const hasCool = states.states.some(isCooling);
|
const hasCool = states.states.some(isCooling);
|
||||||
|
const hasDry = states.states.some(isDrying);
|
||||||
|
const hasFan = states.states.some(isFanOnly);
|
||||||
// We differentiate between thermostats that have a target temperature
|
// We differentiate between thermostats that have a target temperature
|
||||||
// range versus ones that have just a target temperature
|
// range versus ones that have just a target temperature
|
||||||
|
|
||||||
@@ -494,6 +510,34 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
// The "cooling" series uses steppedArea to shade the area below the current
|
// The "cooling" series uses steppedArea to shade the area below the current
|
||||||
// temperature when the thermostat is calling for heat.
|
// temperature when the thermostat is calling for heat.
|
||||||
}
|
}
|
||||||
|
if (hasDry) {
|
||||||
|
addDataSet(
|
||||||
|
states.entity_id + "-drying",
|
||||||
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.drying", { name: name })
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.hvac_action.state.drying"
|
||||||
|
),
|
||||||
|
computedStyles.getPropertyValue("--state-climate-dry-color"),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
// The "drying" series uses steppedArea to shade the area below the current
|
||||||
|
// temperature when the climate entity is in dry mode.
|
||||||
|
}
|
||||||
|
if (hasFan) {
|
||||||
|
addDataSet(
|
||||||
|
states.entity_id + "-fan",
|
||||||
|
this.showNames
|
||||||
|
? this.hass.localize("ui.card.climate.fan", { name: name })
|
||||||
|
: this.hass.localize(
|
||||||
|
"component.climate.entity_component._.state_attributes.hvac_action.state.fan"
|
||||||
|
),
|
||||||
|
computedStyles.getPropertyValue("--state-climate-fan_only-color"),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
// The "fan" series uses steppedArea to shade the area below the current
|
||||||
|
// temperature when the climate entity is in fan_only mode.
|
||||||
|
}
|
||||||
|
|
||||||
if (hasTargetRange) {
|
if (hasTargetRange) {
|
||||||
addDataSet(
|
addDataSet(
|
||||||
@@ -546,6 +590,12 @@ export class StateHistoryChartLine extends LitElement {
|
|||||||
if (hasCool) {
|
if (hasCool) {
|
||||||
series.push(isCooling(entityState) ? curTemp : null);
|
series.push(isCooling(entityState) ? curTemp : null);
|
||||||
}
|
}
|
||||||
|
if (hasDry) {
|
||||||
|
series.push(isDrying(entityState) ? curTemp : null);
|
||||||
|
}
|
||||||
|
if (hasFan) {
|
||||||
|
series.push(isFanOnly(entityState) ? curTemp : null);
|
||||||
|
}
|
||||||
if (hasTargetRange) {
|
if (hasTargetRange) {
|
||||||
const targetHigh = safeParseFloat(
|
const targetHigh = safeParseFloat(
|
||||||
entityState.attributes.target_temp_high
|
entityState.attributes.target_temp_high
|
||||||
|
|||||||
@@ -129,6 +129,8 @@
|
|||||||
"current_temperature": "{name} current temperature",
|
"current_temperature": "{name} current temperature",
|
||||||
"heating": "{name} heating",
|
"heating": "{name} heating",
|
||||||
"cooling": "{name} cooling",
|
"cooling": "{name} cooling",
|
||||||
|
"drying": "{name} drying",
|
||||||
|
"fan": "{name} fan only",
|
||||||
"high": "high",
|
"high": "high",
|
||||||
"low": "low",
|
"low": "low",
|
||||||
"mode": "Mode",
|
"mode": "Mode",
|
||||||
|
|||||||
Reference in New Issue
Block a user