Renamed class functions according to the new constant value

This commit is contained in:
Lorenzo Prosseda 2024-11-15 00:54:21 +01:00
parent 61a282f7d3
commit ca788300d1
No known key found for this signature in database
GPG key ID: 316B7756E0101C16
3 changed files with 15 additions and 15 deletions

View file

@ -6,17 +6,17 @@ namespace airton {
static const char *const TAG = "airton.climate"; static const char *const TAG = "airton.climate";
void AirtonClimate::set_sleep_state(bool state) { void AirtonClimate::set_sleep_mode_state(bool state) {
if (state != this->settings_.sleep_state) { if (state != this->settings_.sleep_state) {
this->settings_.sleep_state = state; this->settings_.sleep_state = state;
#ifdef USE_SWITCH #ifdef USE_SWITCH
this->sleep_switch_->publish_state(state); this->sleep_mode_switch_->publish_state(state);
#endif #endif
this->airton_rtc_.save(&this->settings_); this->airton_rtc_.save(&this->settings_);
} }
} }
bool AirtonClimate::get_sleep_state() const { return this->settings_.sleep_state; } bool AirtonClimate::get_sleep_mode_state() const { return this->settings_.sleep_state; }
void AirtonClimate::set_display_state(bool state) { void AirtonClimate::set_display_state(bool state) {
if (state != this->settings_.display_state) { if (state != this->settings_.display_state) {
@ -31,10 +31,10 @@ void AirtonClimate::set_display_state(bool state) {
bool AirtonClimate::get_display_state() const { return this->settings_.display_state; } bool AirtonClimate::get_display_state() const { return this->settings_.display_state; }
#ifdef USE_SWITCH #ifdef USE_SWITCH
void AirtonClimate::set_sleep_switch(switch_::Switch *sw) { void AirtonClimate::set_sleep_mode_switch(switch_::Switch *sw) {
this->sleep_switch_ = sw; this->sleep_mode_switch_ = sw;
if (this->sleep_switch_ != nullptr) { if (this->sleep_mode_switch_ != nullptr) {
this->sleep_switch_->publish_state(this->get_sleep_state()); this->sleep_mode_switch_->publish_state(this->get_sleep_mode_state());
} }
} }
void AirtonClimate::set_display_switch(switch_::Switch *sw) { void AirtonClimate::set_display_switch(switch_::Switch *sw) {
@ -187,7 +187,7 @@ uint8_t AirtonClimate::operation_settings_() {
if (this->get_display_state()) { // Set LED display if (this->get_display_state()) { // Set LED display
settings |= (1 << 7); settings |= (1 << 7);
} }
if (this->get_sleep_state()) { // Set sleep mode if (this->get_sleep_mode_state()) { // Set sleep mode
settings |= (1 << 1); settings |= (1 << 1);
} }
settings |= 0b01000100; // Set Health and NotAutoOn bits as per default settings |= 0b01000100; // Set Health and NotAutoOn bits as per default
@ -265,7 +265,7 @@ bool AirtonClimate::parse_state_frame_(uint8_t const frame[]) {
this->set_display_state(display_light != 0); this->set_display_state(display_light != 0);
uint8_t sleep_mode = frame[5] & 0b00000010; // Mask anything but the second bit uint8_t sleep_mode = frame[5] & 0b00000010; // Mask anything but the second bit
this->set_sleep_state(sleep_mode != 0); this->set_sleep_mode_state(sleep_mode != 0);
this->publish_state(); this->publish_state();
return true; return true;

View file

@ -50,11 +50,11 @@ struct AirtonSettings {
class AirtonClimate : public climate_ir::ClimateIR { class AirtonClimate : public climate_ir::ClimateIR {
#ifdef USE_SWITCH #ifdef USE_SWITCH
public: public:
void set_sleep_switch(switch_::Switch *sw); void set_sleep_mode_switch(switch_::Switch *sw);
void set_display_switch(switch_::Switch *sw); void set_display_switch(switch_::Switch *sw);
protected: protected:
switch_::Switch *sleep_switch_{nullptr}; switch_::Switch *sleep_mode_switch_{nullptr};
switch_::Switch *display_switch_{nullptr}; switch_::Switch *display_switch_{nullptr};
#endif #endif
public: public:
@ -63,8 +63,8 @@ class AirtonClimate : public climate_ir::ClimateIR {
{climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, climate::CLIMATE_FAN_MEDIUM, {climate::CLIMATE_FAN_AUTO, climate::CLIMATE_FAN_LOW, climate::CLIMATE_FAN_MEDIUM,
climate::CLIMATE_FAN_HIGH}, climate::CLIMATE_FAN_HIGH},
{climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL}) {} {climate::CLIMATE_SWING_OFF, climate::CLIMATE_SWING_VERTICAL}) {}
void set_sleep_state(bool state); void set_sleep_mode_state(bool state);
bool get_sleep_state() const; bool get_sleep_mode_state() const;
void set_display_state(bool state); void set_display_state(bool state);
bool get_display_state() const; bool get_display_state() const;

View file

@ -4,8 +4,8 @@ namespace esphome {
namespace airton { namespace airton {
void SleepSwitch::write_state(bool state) { void SleepSwitch::write_state(bool state) {
if (this->parent_->get_sleep_state() != state) { if (this->parent_->get_sleep_mode_state() != state) {
this->parent_->set_sleep_state(state); this->parent_->set_sleep_mode_state(state);
} }
this->publish_state(state); this->publish_state(state);
} }