Skip to content

Commit

Permalink
more complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
KazWolfe committed Jun 25, 2024
1 parent 7a39c26 commit c2f1076
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ void MitsubishiUART::control(const climate::ClimateCall &call) {
// Queue the packet to be sent first (so any subsequent update packets come *after* our changes)
hp_bridge_.send_packet(set_request_packet);

// Publish state and any sensor changes (shouldn't be any a a result of this function, but
// Publish state and any sensor changes (shouldn't be any a result of this function, but
// since they lazy-publish, no harm in trying)
do_publish_();
};
}

} // namespace mitsubishi_itp
} // namespace esphome
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@ void MitsubishiUART::process_packet(const Packet &packet) {
ESP_LOGI(TAG, "Generic unhandled packet type %x received.", packet.get_packet_type());
ESP_LOGD(TAG, "%s", packet.to_string().c_str());
route_packet_(packet);
};
}

void MitsubishiUART::process_packet(const ConnectRequestPacket &packet) {
// Nothing to be done for these except forward them along from thermostat to heat pump.
// This method defined so that these packets are not "unhandled"
ESP_LOGV(TAG, "Passing through inbound %s", packet.to_string().c_str());
route_packet_(packet);
};
}
void MitsubishiUART::process_packet(const ConnectResponsePacket &packet) {
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());
route_packet_(packet);
// Not sure if there's any needed content in this response, so assume we're connected.
hp_connected_ = true;
ESP_LOGI(TAG, "Heatpump connected.");
};
}

void MitsubishiUART::process_packet(const CapabilitiesRequestPacket &packet) {
// Nothing to be done for these except forward them along from thermostat to heat pump.
// This method defined so that these packets are not "unhandled"
ESP_LOGV(TAG, "Passing through inbound %s", packet.to_string().c_str());
route_packet_(packet);
};
}
void MitsubishiUART::process_packet(const CapabilitiesResponsePacket &packet) {
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());
route_packet_(packet);
Expand All @@ -50,7 +50,7 @@ void MitsubishiUART::process_packet(const CapabilitiesResponsePacket &packet) {
hp_connected_ = true;
capabilities_cache_ = packet;
ESP_LOGI(TAG, "Received heat pump identification packet.");
};
}

void MitsubishiUART::process_packet(const GetRequestPacket &packet) {
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());
Expand Down Expand Up @@ -217,7 +217,7 @@ void MitsubishiUART::process_packet(const SettingsGetResponsePacket &packet) {
ESP_LOGW(TAG, "Vane in unknown horizontal position %x", packet.get_horizontal_vane());
}
publish_on_update_ |= (old_horizontal_vane_position != horizontal_vane_position_select_->state);
};
}

void MitsubishiUART::process_packet(const CurrentTempGetResponsePacket &packet) {
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());
Expand All @@ -233,7 +233,7 @@ void MitsubishiUART::process_packet(const CurrentTempGetResponsePacket &packet)
outdoor_temperature_sensor_->raw_state = packet.get_outdoor_temp();
publish_on_update_ |= (old_outdoor_temperature != outdoor_temperature_sensor_->raw_state);
}
};
}

void MitsubishiUART::process_packet(const StatusGetResponsePacket &packet) {
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());
Expand Down Expand Up @@ -292,7 +292,7 @@ void MitsubishiUART::process_packet(const StatusGetResponsePacket &packet) {

publish_on_update_ |= (old_compressor_frequency != compressor_frequency_sensor_->raw_state);
}
};
}
void MitsubishiUART::process_packet(const RunStateGetResponsePacket &packet) {
ESP_LOGV(TAG, "Processing %s", packet.to_string().c_str());
route_packet_(packet);
Expand Down Expand Up @@ -433,8 +433,10 @@ void MitsubishiUART::process_packet(const ThermostatStateUploadPacket &packet) {

ESP_LOGV(TAG, "Processing inbound %s", packet.to_string().c_str());

if (packet.get_flags() & 0x08) this->mhk_state_.heat_setpoint_ = packet.get_heat_setpoint();
if (packet.get_flags() & 0x10) this->mhk_state_.cool_setpoint_ = packet.get_cool_setpoint();
if (packet.get_flags() & 0x08)
this->mhk_state_.heat_setpoint_ = packet.get_heat_setpoint();
if (packet.get_flags() & 0x10)
this->mhk_state_.cool_setpoint_ = packet.get_cool_setpoint();

ts_bridge_->send_packet(SetResponsePacket());
}
Expand Down Expand Up @@ -463,7 +465,7 @@ void MitsubishiUART::handle_thermostat_state_download_request(const GetRequestPa
if (!enhanced_mhk_support_) {
route_packet_(packet);
return;
};
}

auto response = ThermostatStateDownloadResponsePacket();

Expand All @@ -475,7 +477,7 @@ void MitsubishiUART::handle_thermostat_state_download_request(const GetRequestPa
response.set_timestamp(this->time_source_->now());
} else {
ESP_LOGW(TAG, "No time source specified. Cannot provide accurate time!");
response.set_timestamp(ESPTime::from_epoch_utc(1704067200)); // 2024-01-01 00:00:00Z
response.set_timestamp(ESPTime::from_epoch_utc(1704067200)); // 2024-01-01 00:00:00Z
}

ts_bridge_->send_packet(response);
Expand All @@ -485,7 +487,7 @@ void MitsubishiUART::handle_thermostat_ab_get_request(const GetRequestPacket &pa
if (!enhanced_mhk_support_) {
route_packet_(packet);
return;
};
}

auto response = ThermostatABGetResponsePacket();

Expand Down
3 changes: 1 addition & 2 deletions esphome/components/mitsubishi_itp/mitsubishi_uart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ void MitsubishiUART::do_publish_() {
ESP_LOGI(TAG, "Outdoor temp differs, do publish");
outdoor_temperature_sensor_->publish_state(outdoor_temperature_sensor_->raw_state);
}
if (thermostat_humidity_sensor_ &&
(thermostat_humidity_sensor_->raw_state != thermostat_humidity_sensor_->state)) {
if (thermostat_humidity_sensor_ && (thermostat_humidity_sensor_->raw_state != thermostat_humidity_sensor_->state)) {
ESP_LOGI(TAG, "Thermostat humidity differs, do publish");
thermostat_humidity_sensor_->publish_state(thermostat_humidity_sensor_->raw_state);
}
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/mitsubishi_itp/mitsubishi_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class MitsubishiUART : public PollingComponent, public climate::Climate, public
void set_active_mode(const bool active) { active_mode_ = active; };

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

void set_time_source(time::RealTimeClock *rtc) { time_source_ = rtc; }

Expand Down
18 changes: 9 additions & 9 deletions esphome/components/mitsubishi_itp/muart_packet-derived.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,19 +296,19 @@ std::string ThermostatHelloPacket::get_thermostat_version_string() const {
}

// ThermostatStateUploadPacket functions
int32_t ThermostatStateUploadPacket::get_thermostat_timestamp(esphome::ESPTime *outTimestamp) const {
time_t ThermostatStateUploadPacket::get_thermostat_timestamp(esphome::ESPTime *out_timestamp) const {
int32_be_t magic;
std::memcpy(&magic, pkt_.get_payload_bytes(PLINDEX_THERMOSTAT_TIMESTAMP), 4);

outTimestamp->second = magic & 63;
outTimestamp->minute = (magic >> 6) & 63;
outTimestamp->hour = (magic >> 12) & 31;
outTimestamp->day_of_month = (magic >> 17) & 31;
outTimestamp->month = (magic >> 22) & 15;
outTimestamp->year = (magic >> 26) + 2017;
out_timestamp->second = magic & 63;
out_timestamp->minute = (magic >> 6) & 63;
out_timestamp->hour = (magic >> 12) & 31;
out_timestamp->day_of_month = (magic >> 17) & 31;
out_timestamp->month = (magic >> 22) & 15;
out_timestamp->year = (magic >> 26) + 2017;

outTimestamp->recalc_timestamp_local();
return outTimestamp->timestamp;
out_timestamp->recalc_timestamp_local();
return out_timestamp->timestamp;
}

uint8_t ThermostatStateUploadPacket::get_auto_mode() const { return pkt_.get_payload_byte(PLINDEX_AUTO_MODE); }
Expand Down
2 changes: 1 addition & 1 deletion esphome/components/mitsubishi_itp/muart_packet.h
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ class ThermostatStateUploadPacket : public Packet {
pkt_.set_payload_byte(0, static_cast<uint8_t>(SetCommand::THERMOSTAT_STATE_UPLOAD));
}

int32_t get_thermostat_timestamp(ESPTime *outTimestamp) const;
time_t get_thermostat_timestamp(esphome::ESPTime *out_timestamp) const;
uint8_t get_auto_mode() const;
float get_heat_setpoint() const;
float get_cool_setpoint() const;
Expand Down
4 changes: 2 additions & 2 deletions esphome/components/mitsubishi_itp/muart_rawpacket.h
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,8 @@ class RawPacket {
uint8_t get_payload_byte(const uint8_t payload_byte_index) const {
return packet_bytes_[PACKET_HEADER_SIZE + payload_byte_index];
};
const uint8_t *get_payload_bytes(size_t startIndex = 0) const {
return &packet_bytes_[PACKET_HEADER_SIZE + startIndex];
const uint8_t *get_payload_bytes(size_t start_index = 0) const {
return &packet_bytes_[PACKET_HEADER_SIZE + start_index];
}

private:
Expand Down

0 comments on commit c2f1076

Please sign in to comment.