Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add horizontal swing to climate #22043

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions gallery/src/pages/lovelace/thermostat-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,11 @@ const ENTITIES = [
friendly_name: "Sensibo purifier",
fan_modes: ["low", "high"],
fan_mode: "low",
swing_modes: ["on", "off", "both", "vertical", "horizontal"],
swing_mode: "vertical",
supported_features: 41,
swing_modes: ["both", "rangefull", "off"],
swing_mode: "rangefull",
swing_horizontal_modes: ["both", "rangefull", "off"],
swing_horizontal_mode: "both",
supported_features: 553,
Comment on lines +89 to +93
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verify the validity of 'rangefull' as a swing mode option

It appears that 'rangefull' is used as a swing mode option in both swing_modes and swing_horizontal_modes. Please confirm that 'rangefull' is a valid and recognized swing mode value for the Sensibo device. If it's a typo and should be 'range_full' or another standard value, consider correcting it to ensure compatibility.

Apply this diff if correction is needed:

     swing_modes: ["both", "rangefull", "off"],
     swing_mode: "rangefull",
     swing_horizontal_modes: ["both", "rangefull", "off"],
     swing_horizontal_mode: "both",
     supported_features: 553,
     swing_modes: ["both", "range_full", "off"],
     swing_mode: "range_full",
     swing_horizontal_modes: ["both", "range_full", "off"],
     swing_horizontal_mode: "both",
     supported_features: 553,

Committable suggestion was skipped due to low confidence.

}),
getEntity("climate", "unavailable", "unavailable", {
supported_features: 43,
Expand Down Expand Up @@ -188,11 +190,13 @@ const CONFIGS = [
- type: climate-swing-modes
style: icons
swing_modes:
- 'on'
- 'both'
- 'rangefull'
- 'off'
swing_horizontal_modes:
- 'both'
- 'vertical'
- 'horizontal'
- 'rangefull'
- 'off'
`,
gjohansson-ST marked this conversation as resolved.
Show resolved Hide resolved
},
{
Expand Down
3 changes: 3 additions & 0 deletions gallery/src/pages/lovelace/tile-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,19 @@ const ENTITIES = [
fan_modes: ["on_low", "on_high", "auto_low", "auto_high", "off"],
preset_modes: ["home", "eco", "away"],
swing_modes: ["auto", "1", "2", "3", "off"],
switch_horizontal_modes: ["auto", "4", "5", "6", "off"],
current_temperature: 23,
target_temp_high: 24,
target_temp_low: 21,
fan_mode: "auto_low",
preset_mode: "home",
swing_mode: "auto",
swing_horizontal_mode: "off",
supported_features:
ClimateEntityFeature.TURN_ON +
ClimateEntityFeature.TURN_OFF +
ClimateEntityFeature.SWING_MODE +
ClimateEntityFeature.SWING_HORIZONTAL_MODE +
ClimateEntityFeature.PRESET_MODE +
ClimateEntityFeature.FAN_MODE +
ClimateEntityFeature.TARGET_TEMPERATURE_RANGE,
Expand Down
3 changes: 3 additions & 0 deletions src/data/climate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ export type ClimateEntity = HassEntityBase & {
preset_modes?: string[];
swing_mode?: string;
swing_modes?: string[];
swing_horizontal_mode?: string;
swing_horizontal_modes?: string[];
aux_heat?: "on" | "off";
};
};
Expand All @@ -75,6 +77,7 @@ export const enum ClimateEntityFeature {
AUX_HEAT = 64,
TURN_OFF = 128,
TURN_ON = 256,
SWING_HORIZONTAL_MODE = 512,
}

const hvacModeOrdering = HVAC_MODES.reduce(
Expand Down
81 changes: 69 additions & 12 deletions src/dialogs/more-info/controls/more-info-climate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ class MoreInfoClimate extends LitElement {
stateObj,
ClimateEntityFeature.SWING_MODE
);
const supportSwingHorizontalMode = supportsFeature(
stateObj,
ClimateEntityFeature.SWING_HORIZONTAL_MODE
);

const currentTemperature = this.stateObj.attributes.current_temperature;
const currentHumidity = this.stateObj.attributes.current_humidity;
Expand Down Expand Up @@ -197,10 +201,7 @@ class MoreInfoClimate extends LitElement {
${supportPresetMode && stateObj.attributes.preset_modes
? html`
<ha-control-select-menu
.label=${this.hass.formatEntityAttributeName(
stateObj,
"preset_mode"
)}
.label=${this.hass.localize("ui.card.climate.preset")}
.value=${stateObj.attributes.preset_mode}
.disabled=${this.stateObj.state === UNAVAILABLE}
fixedMenuPosition
Expand Down Expand Up @@ -248,10 +249,7 @@ class MoreInfoClimate extends LitElement {
${supportFanMode && stateObj.attributes.fan_modes
? html`
<ha-control-select-menu
.label=${this.hass.formatEntityAttributeName(
stateObj,
"fan_mode"
)}
.label=${this.hass.localize("ui.card.climate.fan")}
.value=${stateObj.attributes.fan_mode}
.disabled=${this.stateObj.state === UNAVAILABLE}
fixedMenuPosition
Expand Down Expand Up @@ -296,10 +294,9 @@ class MoreInfoClimate extends LitElement {
${supportSwingMode && stateObj.attributes.swing_modes
? html`
<ha-control-select-menu
.label=${this.hass.formatEntityAttributeName(
stateObj,
"swing_mode"
)}
.label=${supportSwingHorizontalMode
? this.hass.localize("ui.card.climate.vertical_swing")
: this.hass.localize("ui.card.climate.swing")}
.value=${stateObj.attributes.swing_mode}
.disabled=${this.stateObj.state === UNAVAILABLE}
fixedMenuPosition
Expand Down Expand Up @@ -344,6 +341,56 @@ class MoreInfoClimate extends LitElement {
</ha-control-select-menu>
`
: nothing}
${supportSwingHorizontalMode &&
stateObj.attributes.swing_horizontal_modes
? html`
<ha-control-select-menu
.label=${this.hass.localize("ui.card.climate.horizontal_swing")}
.value=${stateObj.attributes.swing_horizontal_mode}
.disabled=${this.stateObj.state === UNAVAILABLE}
fixedMenuPosition
naturalMenuWidth
@selected=${this._handleSwingHorizontalmodeChanged}
@closed=${stopPropagation}
>
${stateObj.attributes.swing_horizontal_mode
? html`
<ha-attribute-icon
slot="icon"
.hass=${this.hass}
.stateObj=${stateObj}
attribute="swing_horizontal_mode"
.attributeValue=${stateObj.attributes
.swing_horizontal_mode}
></ha-attribute-icon>
`
: html`
<ha-svg-icon
slot="icon"
.path=${mdiArrowOscillating}
></ha-svg-icon>
`}
${stateObj.attributes.swing_horizontal_modes!.map(
(mode) => html`
<ha-list-item .value=${mode} graphic="icon">
<ha-attribute-icon
slot="graphic"
.hass=${this.hass}
.stateObj=${stateObj}
attribute="swing_horizontal_mode"
.attributeValue=${mode}
></ha-attribute-icon>
${this.hass.formatEntityAttributeValue(
stateObj,
"swing_horizontal_mode",
mode
)}
</ha-list-item>
`
)}
</ha-control-select-menu>
`
: nothing}
</ha-more-info-control-select-container>
`;
}
Expand Down Expand Up @@ -380,6 +427,16 @@ class MoreInfoClimate extends LitElement {
);
}

private _handleSwingHorizontalmodeChanged(ev) {
const newVal = ev.target.value;
this._callServiceHelper(
this.stateObj!.attributes.swing_horizontal_mode,
newVal,
"set_swing_horizontal_mode",
{ swing_horizontal_mode: newVal }
);
}

private _handlePresetmodeChanged(ev) {
const newVal = ev.target.value || null;
if (newVal) {
Expand Down
Loading
Loading