mirror of
https://github.com/GrKoR/esphome_aux_ac_component.git
synced 2025-12-06 11:36:55 +03:00
Compare commits
2 Commits
5a165d3a3d
...
2e0c421c9f
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2e0c421c9f | ||
|
|
53414d8ab4 |
@@ -26,6 +26,7 @@ from esphome.const import (
|
||||
DEVICE_CLASS_TEMPERATURE,
|
||||
DEVICE_CLASS_POWER_FACTOR,
|
||||
STATE_CLASS_MEASUREMENT,
|
||||
__version__
|
||||
)
|
||||
from esphome.components.climate import (
|
||||
ClimateMode,
|
||||
@@ -127,6 +128,12 @@ AirConPowerLimitationOnAction = aux_ac_ns.class_(
|
||||
)
|
||||
|
||||
|
||||
def use_new_api():
|
||||
esphome_current_version = tuple(map(int, __version__.split('.')))
|
||||
esphome_bc_version = tuple(map(int, "2025.11.0".split('.')))
|
||||
return esphome_current_version >= esphome_bc_version
|
||||
|
||||
|
||||
def validate_packet_timeout(value):
|
||||
minV = AC_PACKET_TIMEOUT_MIN
|
||||
maxV = AC_PACKET_TIMEOUT_MAX
|
||||
@@ -426,6 +433,16 @@ async def to_code(config):
|
||||
cg.add(var.set_supported_swing_modes(config[CONF_SUPPORTED_SWING_MODES]))
|
||||
if CONF_SUPPORTED_PRESETS in config:
|
||||
cg.add(var.set_supported_presets(config[CONF_SUPPORTED_PRESETS]))
|
||||
if use_new_api():
|
||||
if CONF_CUSTOM_PRESETS in config:
|
||||
presets = config[CONF_CUSTOM_PRESETS]
|
||||
c_str_presets = [cg.RawExpression(f"aux_ac::Constants::{p}.c_str()") for p in presets]
|
||||
cg.add(var.set_custom_presets(c_str_presets))
|
||||
if CONF_CUSTOM_FAN_MODES in config:
|
||||
fan_modes = config[CONF_CUSTOM_FAN_MODES]
|
||||
c_str_fan_modes = [cg.RawExpression(f"aux_ac::Constants::{p}.c_str()") for p in fan_modes]
|
||||
cg.add(var.set_custom_fan_modes(c_str_fan_modes))
|
||||
else:
|
||||
if CONF_CUSTOM_PRESETS in config:
|
||||
cg.add(var.set_custom_presets(config[CONF_CUSTOM_PRESETS]))
|
||||
if CONF_CUSTOM_FAN_MODES in config:
|
||||
|
||||
Reference in New Issue
Block a user