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

Optional Turbo Mode #227

Open
wants to merge 1 commit into
base: main
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
9 changes: 9 additions & 0 deletions components/samsung_ac/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@
CONF_CAPABILITIES = "capabilities"
CONF_CAPABILITIES_HORIZONTAL_SWING = "horizontal_swing"
CONF_CAPABILITIES_VERTICAL_SWING = "vertical_swing"
CONF_CAPABILITIES_TURBO_MODE = "turbo_mode"

CONF_PRESETS = "presets"
CONF_PRESET_NAME = "name"
Expand Down Expand Up @@ -121,6 +122,7 @@ def preset_entry(name: str, value: int, displayName: str):
{
cv.Optional(CONF_CAPABILITIES_HORIZONTAL_SWING, default=False): cv.boolean,
cv.Optional(CONF_CAPABILITIES_VERTICAL_SWING, default=False): cv.boolean,
cv.Optional(CONF_CAPABILITIES_TURBO_MODE, default=False): cv.boolean,
cv.Optional(CONF_PRESETS): cv.Schema(
dict(
[
Expand Down Expand Up @@ -370,6 +372,13 @@ async def to_code(config):
)
)

if CONF_CAPABILITIES_TURBO_MODE in capabilities:
cg.add(
var_dev.set_supports_turbo_mode(
capabilities[CONF_CAPABILITIES_TURBO_MODE]
)
)

none_added = False
presets = capabilities.get(CONF_PRESETS, {})

Expand Down
10 changes: 7 additions & 3 deletions components/samsung_ac/samsung_ac_device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,13 @@ namespace esphome

traits.set_supported_fan_modes(fan);

std::set<std::string> customFan;
customFan.insert("Turbo");
traits.set_supported_custom_fan_modes(customFan);
bool t = device->supports_turbo_mode();
if (t)
{
std::set<std::string> customFan;
customFan.insert("Turbo");
traits.set_supported_custom_fan_modes(customFan);
}

auto supported = device->get_supported_alt_modes();
if (!supported->empty())
Expand Down
11 changes: 11 additions & 0 deletions components/samsung_ac/samsung_ac_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,11 @@ namespace esphome
return supports_vertical_swing_;
}

bool supports_turbo_mode()
{
return supports_turbo_mode_;
}

void set_supports_horizontal_swing(bool value)
{
supports_horizontal_swing_ = value;
Expand All @@ -469,6 +474,11 @@ namespace esphome
supports_vertical_swing_ = value;
}

void set_supports_turbo_mode(bool value)
{
supports_turbo_mode_ = value;
}

void add_alt_mode(const AltModeName &name, AltMode value)
{
AltModeDesc desc;
Expand Down Expand Up @@ -498,6 +508,7 @@ namespace esphome
protected:
bool supports_horizontal_swing_{false};
bool supports_vertical_swing_{false};
bool supports_turbo_mode_{false};
std::vector<AltModeDesc> alt_modes;

Protocol *protocol{nullptr};
Expand Down
1 change: 1 addition & 0 deletions example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ samsung_ac:
capabilities:
vertical_swing: true
horizontal_swing: true
turbo_mode: true
# Presets define special AC modes like Windfree, Eco, and so on.
# The following modes are available: sleep, quiet, fast, longreach, windfree, eco.
presets:
Expand Down
Loading