From 5ccc9924cda8afa837bdc673143fd9df83e6b918 Mon Sep 17 00:00:00 2001 From: Sammy1Am <467704+Sammy1Am@users.noreply.github.com> Date: Tue, 8 Oct 2024 06:20:20 +0000 Subject: [PATCH] Re-add battery text-sensor --- .../mitsubishi_itp/text_sensor/mitp_text-sensor.cpp | 6 ++++++ .../mitsubishi_itp/text_sensor/mitp_text-sensor.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.cpp b/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.cpp index 892c50ed171f..869c49d20c18 100644 --- a/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.cpp +++ b/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.cpp @@ -19,5 +19,11 @@ void ErrorCodeSensor::process_packet(const ErrorStateGetResponsePacket &packet) } } +void ThermostatBatterySensor::process_packet(const ThermostatSensorStatusPacket &packet) { + if (packet.get_flags() & 0x08) { + mitp_text_sensor_state_ = THERMOSTAT_BATTERY_STATE_NAMES[packet.get_thermostat_battery_state()]; + } +} + } // namespace mitsubishi_itp } // namespace esphome diff --git a/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.h b/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.h index 198f1d41f145..82914015f2fb 100644 --- a/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.h +++ b/esphome/components/mitsubishi_itp/text_sensor/mitp_text-sensor.h @@ -29,5 +29,9 @@ class ErrorCodeSensor : public MITPTextSensor { void process_packet(const ErrorStateGetResponsePacket &packet) override; }; +class ThermostatBatterySensor : public MITPTextSensor { + void process_packet(const ThermostatSensorStatusPacket &packet) override; +}; + } // namespace mitsubishi_itp } // namespace esphome