diff --git a/README.md b/README.md index 44f2078..98e74dd 100644 --- a/README.md +++ b/README.md @@ -80,9 +80,10 @@ things compile correctly, you will need to: Files") 5. You may also have to delete the _esphomenodename_ directory that corresponds with your _esphomenodename.yaml_ configuration file - completely. Testing with ESPHome 0.18.x showed this to be necessary to get - the cached copy of src/esphome-mitsubishiheatpump to go away entirely, as - the "Clean Build Files" isn't as thorough as one would like. + completely. This directory may exist in your base config directory, + or in `config/.esphome/build`. Testing with ESPHome 0.18.x showed this + to be necessary to get the cached copy of src/esphome-mitsubishiheatpump to + go away entirely, as the "Clean Build Files" isn't as thorough as one would like. *Note:* Failure to delete the old source directory and remove the `includes` and `libraries` lines will likely result in compilation errors complaining diff --git a/components/mitsubishi_heatpump/climate.py b/components/mitsubishi_heatpump/climate.py index 62ea259..d521468 100644 --- a/components/mitsubishi_heatpump/climate.py +++ b/components/mitsubishi_heatpump/climate.py @@ -16,16 +16,18 @@ from esphome.core import CORE, coroutine AUTO_LOAD = ["climate"] CONF_SUPPORTS = "supports" -DEFAULT_CLIMATE_MODES = ['HEAT_COOL', 'COOL', 'HEAT', 'DRY', 'FAN_ONLY'] -DEFAULT_FAN_MODES = ['AUTO', 'DIFFUSE', 'LOW', 'MEDIUM', 'MIDDLE', 'HIGH'] -DEFAULT_SWING_MODES = ['OFF', 'VERTICAL'] +DEFAULT_CLIMATE_MODES = ["HEAT_COOL", "COOL", "HEAT", "DRY", "FAN_ONLY"] +DEFAULT_FAN_MODES = ["AUTO", "DIFFUSE", "LOW", "MEDIUM", "MIDDLE", "HIGH"] +DEFAULT_SWING_MODES = ["OFF", "VERTICAL"] -MitsubishiHeatPump = cg.global_ns.class_("MitsubishiHeatPump", climate.Climate, cg.PollingComponent) +MitsubishiHeatPump = cg.global_ns.class_( + "MitsubishiHeatPump", climate.Climate, cg.PollingComponent +) def valid_uart(uart): if CORE.is_esp8266: - uarts = ["UART0"] # UART1 is tx-only + uarts = ["UART0"] # UART1 is tx-only elif CORE.is_esp32: uarts = ["UART0", "UART1", "UART2"] else: @@ -39,14 +41,11 @@ CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( cv.GenerateID(): cv.declare_id(MitsubishiHeatPump), cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, cv.Optional(CONF_BAUD_RATE): cv.positive_int, - # If polling interval is greater than 9 seconds, the HeatPump library # reconnects, but doesn't then follow up with our data request. cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( - cv.update_interval, - cv.Range(max=cv.TimePeriod(milliseconds=9000)) + cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000)) ), - # Optionally override the supported ClimateTraits. cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( { @@ -65,7 +64,7 @@ CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend( @coroutine def to_code(config): serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] - var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f'&{serial}')) + var = cg.new_Pvariable(config[CONF_ID], cg.RawExpression(f"&{serial}")) if CONF_BAUD_RATE in config: cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) @@ -74,7 +73,7 @@ def to_code(config): traits = var.config_traits() for mode in supports[CONF_MODE]: - if mode == 'OFF': + if mode == "OFF": continue cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) @@ -82,9 +81,14 @@ def to_code(config): cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode])) for mode in supports[CONF_SWING_MODE]: - cg.add(traits.add_supported_swing_mode(climate.CLIMATE_SWING_MODES[mode])) + cg.add(traits.add_supported_swing_mode( + climate.CLIMATE_SWING_MODES[mode] + )) yield cg.register_component(var, config) yield climate.register_climate(var, config) - cg.add_library("https://github.com/SwiCago/HeatPump", None) - + cg.add_library( + name="HeatPump", + repository="https://github.com/SwiCago/HeatPump", + version="ed3b700dd4b110253368cc9f6960516d228e33d8", + ) diff --git a/components/mitsubishi_heatpump/espmhp.cpp b/components/mitsubishi_heatpump/espmhp.cpp index 70fe468..02223a1 100644 --- a/components/mitsubishi_heatpump/espmhp.cpp +++ b/components/mitsubishi_heatpump/espmhp.cpp @@ -456,7 +456,7 @@ void MitsubishiHeatPump::setup() { ESP_LOGCONFIG(TAG, "Calling hp->connect(%p)", this->get_hw_serial_()); - if (hp->connect(this->get_hw_serial_(), this->baud_)) { + if (hp->connect(this->get_hw_serial_(), this->baud_, -1, -1)) { hp->sync(); } else { diff --git a/components/mitsubishi_heatpump/espmhp.h b/components/mitsubishi_heatpump/espmhp.h index 834d94f..68d8852 100644 --- a/components/mitsubishi_heatpump/espmhp.h +++ b/components/mitsubishi_heatpump/espmhp.h @@ -28,7 +28,7 @@ using namespace esphome; static const char* TAG = "MitsubishiHeatPump"; // Logging tag -static const char* ESPMHP_VERSION = "2.3.2"; +static const char* ESPMHP_VERSION = "2.4.0"; /* If polling interval is greater than 9 seconds, the HeatPump library reconnects, but doesn't then follow up with our data request.*/