Skip to content
Closed
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
5 changes: 0 additions & 5 deletions esphome/components/mitsubishi_itp/climate.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
CONF_UART_HEATPUMP = "uart_heatpump"
CONF_UART_THERMOSTAT = "uart_thermostat"

CONF_DISABLE_ACTIVE_MODE = "disable_active_mode"
CONF_ENHANCED_MHK_SUPPORT = (
"enhanced_mhk" # EXPERIMENTAL. Will be set to default eventually.
)
Expand Down Expand Up @@ -48,7 +47,6 @@
cv.Optional(CONF_CUSTOM_FAN_MODES, default=["VERYHIGH"]): cv.ensure_list(
validate_custom_fan_modes
),
cv.Optional(CONF_DISABLE_ACTIVE_MODE, default=False): cv.boolean,
cv.Optional(CONF_ENHANCED_MHK_SUPPORT, default=False): cv.boolean,
cv.Optional(CONF_RECALL_SETPOINT, default=False): cv.boolean,
}
Expand Down Expand Up @@ -119,9 +117,6 @@ async def to_code(config):
cg.add(traits.set_supported_custom_fan_modes(config[CONF_CUSTOM_FAN_MODES]))

# Debug Settings
if dam_conf := config.get(CONF_DISABLE_ACTIVE_MODE):
cg.add(getattr(mitp_component, "set_active_mode")(not dam_conf))

if enhanced_mhk_protocol := config.get(CONF_ENHANCED_MHK_SUPPORT):
cg.add(
getattr(mitp_component, "set_enhanced_mhk_support")(enhanced_mhk_protocol)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@ namespace mitsubishi_itp {

// Called to instruct a change of the climate controls
void MitsubishiUART::control(const climate::ClimateCall &call) {
if (!active_mode_)
return; // If we're not in active mode, ignore control requests

SettingsSetRequestPacket set_request_packet = SettingsSetRequestPacket();

// Apply fan settings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -257,9 +257,8 @@ void MitsubishiUART::process_packet(const RemoteTemperatureSetRequestPacket &pac
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());

// Only send this temperature packet to the heatpump if Thermostat is the selected source,
// or we're in passive mode (since in passive mode we're not generating any packets to
// set the temperature) otherwise just respond to the thermostat to keep it happy.
if (current_temperature_source_ == TEMPERATURE_SOURCE_THERMOSTAT || !active_mode_) {
// otherwise just respond to the thermostat to keep it happy.
if (current_temperature_source_ == TEMPERATURE_SOURCE_THERMOSTAT) {
route_packet_(packet);
} else {
ts_bridge_->send_packet(SetResponsePacket());
Expand Down
59 changes: 22 additions & 37 deletions esphome/components/mitsubishi_itp/mitsubishi_itp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,6 @@ void MitsubishiUART::save_preferences_() {
preferences_.save(&prefs);
}

void MitsubishiUART::send_if_active_(const Packet &packet) {
if (active_mode_)
hp_bridge_.send_packet(packet);
}

#define IFACTIVE(dothis) \
if (active_mode_) { \
dothis \
}
#define IFNOTACTIVE(dothis) \
if (!active_mode_) { \
dothis \
}

/* Used for receiving and acting on incoming packets as soon as they're available.
Because packet processing happens as part of the receiving process, packet processing
should not block for very long (e.g. no publishing inside the packet processing)
Expand All @@ -80,7 +66,7 @@ void MitsubishiUART::loop() {
if (current_temperature_source_.empty() || current_temperature_source_ != TEMPERATURE_SOURCE_INTERNAL) {
ESP_LOGD(TAG, "Reminding heat pump to use internal temperature sensor");
// Check to make sure a temperature source is set-- if not, set to internal for sanity reasons
IFACTIVE(this->select_temperature_source(TEMPERATURE_SOURCE_INTERNAL);)
this->select_temperature_source(TEMPERATURE_SOURCE_INTERNAL);
last_received_temperature_ = millis(); // Count this as "receiving" the internal temperature
} else if (!temperature_source_timeout_) {
// If it's been too long since we received a temperature update (and we're not set to Internal)
Expand All @@ -93,7 +79,7 @@ void MitsubishiUART::loop() {
}
temperature_source_timeout_ = true;
// Send a packet to the heat pump to tell it to switch to internal temperature sensing
IFACTIVE(hp_bridge_.send_packet(RemoteTemperatureSetRequestPacket().use_internal_temperature());)
hp_bridge_.send_packet(RemoteTemperatureSetRequestPacket().use_internal_temperature());
}
}
}
Expand Down Expand Up @@ -129,7 +115,7 @@ void MitsubishiUART::update() {

// If we're not yet connected, send off a connection request (we'll check again next update)
if (!hp_connected_) {
IFACTIVE(hp_bridge_.send_packet(ConnectRequestPacket::instance());)
hp_bridge_.send_packet(ConnectRequestPacket::instance());
return;
}

Expand All @@ -138,7 +124,8 @@ void MitsubishiUART::update() {
// autoconf.
// For now, just requesting it as part of our "init loops" is a good first step.
if (!this->capabilities_requested_) {
IFACTIVE(hp_bridge_.send_packet(CapabilitiesRequestPacket::instance()); this->capabilities_requested_ = true;)
hp_bridge_.send_packet(CapabilitiesRequestPacket::instance());
this->capabilities_requested_ = true;
}

// Before requesting additional updates, publish any changes waiting from packets received
Expand All @@ -154,19 +141,20 @@ void MitsubishiUART::update() {
publish_on_update_ = false;
}

IFACTIVE(
// Request an update from the heatpump
// TODO: This isn't a problem *yet*, but sending all these packets every loop might start to cause some issues
// in
// certain configurations or setups. We may want to consider only asking for certain packets on a rarer
// cadence, depending on their utility (e.g. we dont need to check for errors every loop).
hp_bridge_.send_packet(
GetRequestPacket::get_settings_instance()); // Needs to be done before status packet for mode logic to work
if (in_discovery_ || run_state_received_) { hp_bridge_.send_packet(GetRequestPacket::get_runstate_instance()); }
// Request an update from the heatpump
// TODO: This isn't a problem *yet*, but sending all these packets every loop might start to cause some issues
// in
// certain configurations or setups. We may want to consider only asking for certain packets on a rarer
// cadence, depending on their utility (e.g. we dont need to check for errors every loop).
hp_bridge_.send_packet(
GetRequestPacket::get_settings_instance()); // Needs to be done before status packet for mode logic to work
if (in_discovery_ || run_state_received_) {
hp_bridge_.send_packet(GetRequestPacket::get_runstate_instance());
}

hp_bridge_.send_packet(GetRequestPacket::get_status_instance());
hp_bridge_.send_packet(GetRequestPacket::get_current_temp_instance());
hp_bridge_.send_packet(GetRequestPacket::get_error_info_instance());)
hp_bridge_.send_packet(GetRequestPacket::get_status_instance());
hp_bridge_.send_packet(GetRequestPacket::get_current_temp_instance());
hp_bridge_.send_packet(GetRequestPacket::get_error_info_instance());

if (in_discovery_) {
// After criteria met, exit discovery mode
Expand Down Expand Up @@ -198,14 +186,13 @@ bool MitsubishiUART::select_temperature_source(const std::string &state) {

// If we've switched to internal, let the HP know right away
if (TEMPERATURE_SOURCE_INTERNAL == state) {
IFACTIVE(hp_bridge_.send_packet(RemoteTemperatureSetRequestPacket().use_internal_temperature());)
hp_bridge_.send_packet(RemoteTemperatureSetRequestPacket().use_internal_temperature());
}

return true;
}

bool MitsubishiUART::select_vane_position(const std::string &state) {
IFNOTACTIVE(return false;) // Skip this if we're not in active mode
SettingsSetRequestPacket::VaneByte position_byte = SettingsSetRequestPacket::VANE_AUTO;

// NOTE: Annoyed that C++ doesn't have switches for strings, but since this is going to be called
Expand Down Expand Up @@ -235,7 +222,6 @@ bool MitsubishiUART::select_vane_position(const std::string &state) {
}

bool MitsubishiUART::select_horizontal_vane_position(const std::string &state) {
IFNOTACTIVE(return false;) // Skip this if we're not in active mode
SettingsSetRequestPacket::HorizontalVaneByte position_byte = SettingsSetRequestPacket::HV_CENTER;

// NOTE: Annoyed that C++ doesn't have switches for strings, but since this is going to be called
Expand Down Expand Up @@ -284,8 +270,9 @@ void MitsubishiUART::temperature_source_report(const std::string &temperature_so

// Tell the heat pump about the temperature asap, but don't worry about setting it locally, the next update() will
// get it
IFACTIVE(RemoteTemperatureSetRequestPacket pkt = RemoteTemperatureSetRequestPacket(); pkt.set_remote_temperature(v);
hp_bridge_.send_packet(pkt);)
RemoteTemperatureSetRequestPacket pkt = RemoteTemperatureSetRequestPacket();
pkt.set_remote_temperature(v);
hp_bridge_.send_packet(pkt);

// If we've changed the select to reflect a temporary reversion to a different source, change it back.
for (auto *listener : listeners_) {
Expand All @@ -297,8 +284,6 @@ void MitsubishiUART::temperature_source_report(const std::string &temperature_so
void MitsubishiUART::reset_filter_status() {
ESP_LOGI(TAG, "Received a request to reset the filter status.");

IFNOTACTIVE(return;)

SetRunStatePacket pkt = SetRunStatePacket();
pkt.set_filter_reset(true);
hp_bridge_.send_packet(pkt);
Expand Down
6 changes: 0 additions & 6 deletions esphome/components/mitsubishi_itp/mitsubishi_itp.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,6 @@ class MitsubishiUART : public PollingComponent, public climate::Climate, public
// Button triggers
void reset_filter_status();

// Turns on or off actively sending packets
void set_active_mode(const bool active) { active_mode_ = active; };

// Turns on or off Kumo emulation mode
void set_enhanced_mhk_support(const bool supports) { enhanced_mhk_support_ = supports; }

Expand Down Expand Up @@ -176,9 +173,6 @@ class MitsubishiUART : public PollingComponent, public climate::Climate, public
uint32_t last_received_temperature_ = millis();
bool temperature_source_timeout_ = false; // Has the current source timed out?

void send_if_active_(const Packet &packet);
bool active_mode_ = true;

// used to track whether to support/handle the enhanced MHK protocol packets
bool enhanced_mhk_support_ = false;

Expand Down
Loading