Merge branch 'release/2.4.0'

This commit is contained in:
Geoff Davis 2022-04-05 11:55:13 -07:00
commit e90072132c
4 changed files with 24 additions and 19 deletions

View File

@ -80,9 +80,10 @@ things compile correctly, you will need to:
Files") Files")
5. You may also have to delete the _esphomenodename_ directory that 5. You may also have to delete the _esphomenodename_ directory that
corresponds with your _esphomenodename.yaml_ configuration file corresponds with your _esphomenodename.yaml_ configuration file
completely. Testing with ESPHome 0.18.x showed this to be necessary to get completely. This directory may exist in your base config directory,
the cached copy of src/esphome-mitsubishiheatpump to go away entirely, as or in `config/.esphome/build`. Testing with ESPHome 0.18.x showed this
the "Clean Build Files" isn't as thorough as one would like. 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` *Note:* Failure to delete the old source directory and remove the `includes`
and `libraries` lines will likely result in compilation errors complaining and `libraries` lines will likely result in compilation errors complaining

View File

@ -16,11 +16,13 @@ from esphome.core import CORE, coroutine
AUTO_LOAD = ["climate"] AUTO_LOAD = ["climate"]
CONF_SUPPORTS = "supports" CONF_SUPPORTS = "supports"
DEFAULT_CLIMATE_MODES = ['HEAT_COOL', 'COOL', 'HEAT', 'DRY', 'FAN_ONLY'] DEFAULT_CLIMATE_MODES = ["HEAT_COOL", "COOL", "HEAT", "DRY", "FAN_ONLY"]
DEFAULT_FAN_MODES = ['AUTO', 'DIFFUSE', 'LOW', 'MEDIUM', 'MIDDLE', 'HIGH'] DEFAULT_FAN_MODES = ["AUTO", "DIFFUSE", "LOW", "MEDIUM", "MIDDLE", "HIGH"]
DEFAULT_SWING_MODES = ['OFF', 'VERTICAL'] 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): def valid_uart(uart):
@ -39,14 +41,11 @@ CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend(
cv.GenerateID(): cv.declare_id(MitsubishiHeatPump), cv.GenerateID(): cv.declare_id(MitsubishiHeatPump),
cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart, cv.Optional(CONF_HARDWARE_UART, default="UART0"): valid_uart,
cv.Optional(CONF_BAUD_RATE): cv.positive_int, cv.Optional(CONF_BAUD_RATE): cv.positive_int,
# If polling interval is greater than 9 seconds, the HeatPump library # If polling interval is greater than 9 seconds, the HeatPump library
# reconnects, but doesn't then follow up with our data request. # reconnects, but doesn't then follow up with our data request.
cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All( cv.Optional(CONF_UPDATE_INTERVAL, default="500ms"): cv.All(
cv.update_interval, cv.update_interval, cv.Range(max=cv.TimePeriod(milliseconds=9000))
cv.Range(max=cv.TimePeriod(milliseconds=9000))
), ),
# Optionally override the supported ClimateTraits. # Optionally override the supported ClimateTraits.
cv.Optional(CONF_SUPPORTS, default={}): cv.Schema( cv.Optional(CONF_SUPPORTS, default={}): cv.Schema(
{ {
@ -65,7 +64,7 @@ CONFIG_SCHEMA = climate.CLIMATE_SCHEMA.extend(
@coroutine @coroutine
def to_code(config): def to_code(config):
serial = HARDWARE_UART_TO_SERIAL[config[CONF_HARDWARE_UART]] 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: if CONF_BAUD_RATE in config:
cg.add(var.set_baud_rate(config[CONF_BAUD_RATE])) cg.add(var.set_baud_rate(config[CONF_BAUD_RATE]))
@ -74,7 +73,7 @@ def to_code(config):
traits = var.config_traits() traits = var.config_traits()
for mode in supports[CONF_MODE]: for mode in supports[CONF_MODE]:
if mode == 'OFF': if mode == "OFF":
continue continue
cg.add(traits.add_supported_mode(climate.CLIMATE_MODES[mode])) 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])) cg.add(traits.add_supported_fan_mode(climate.CLIMATE_FAN_MODES[mode]))
for mode in supports[CONF_SWING_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 cg.register_component(var, config)
yield climate.register_climate(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",
)

View File

@ -456,7 +456,7 @@ void MitsubishiHeatPump::setup() {
ESP_LOGCONFIG(TAG, "Calling hp->connect(%p)", this->get_hw_serial_()); 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(); hp->sync();
} }
else { else {

View File

@ -28,7 +28,7 @@ using namespace esphome;
static const char* TAG = "MitsubishiHeatPump"; // Logging tag 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 /* If polling interval is greater than 9 seconds, the HeatPump
library reconnects, but doesn't then follow up with our data request.*/ library reconnects, but doesn't then follow up with our data request.*/