Skip to content

Commit

Permalink
Change naming. Update makes it more clear that the values goes in not…
Browse files Browse the repository at this point in the history
… out.
  • Loading branch information
lanwin committed Feb 8, 2024
1 parent 2b0330c commit 5f86c77
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 24 deletions.
18 changes: 9 additions & 9 deletions components/samsung_ac/samsung_ac.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,63 +65,63 @@ namespace esphome
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_room_temperature(value);
dev->update_room_temperature(value);
}

void /*MessageTarget::*/ set_room_humidity(const std::string address, float value) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_room_humidity(value);
dev->update_room_humidity(value);
}

void /*MessageTarget::*/ set_target_temperature(const std::string address, float value) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_target_temperature(value);
dev->update_target_temperature(value);
}

void /*MessageTarget::*/ set_power(const std::string address, bool value) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_power(value);
dev->update_power(value);
}

void /*MessageTarget::*/ set_mode(const std::string address, Mode mode) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_mode(mode);
dev->update_mode(mode);
}

void /*MessageTarget::*/ set_fanmode(const std::string address, FanMode fanmode) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_fanmode(fanmode);
dev->update_fanmode(fanmode);
}

void /*MessageTarget::*/ set_altmode(const std::string address, AltMode altmode) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_altmode(altmode);
dev->update_altmode(altmode);
}

void /*MessageTarget::*/ set_swing_vertical(const std::string address, bool vertical) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_swing_vertical(vertical);
dev->update_swing_vertical(vertical);
}

void /*MessageTarget::*/ set_swing_horizontal(const std::string address, bool horizontal) override
{
Samsung_AC_Device *dev = find_device(address);
if (dev != nullptr)
dev->publish_swing_horizontal(horizontal);
dev->update_swing_horizontal(horizontal);
}

protected:
Expand Down
30 changes: 15 additions & 15 deletions components/samsung_ac/samsung_ac_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ namespace esphome
climate->device = this;
}

void publish_target_temperature(float value)
void update_target_temperature(float value)
{
if (target_temperature != nullptr)
target_temperature->publish_state(value);
Expand All @@ -146,7 +146,7 @@ namespace esphome
optional<bool> _cur_power;
optional<Mode> _cur_mode;

void publish_power(bool value)
void update_power(bool value)
{
_cur_power = value;
if (power != nullptr)
Expand All @@ -155,7 +155,7 @@ namespace esphome
calc_and_publish_mode();
}

void publish_mode(Mode value)
void update_mode(Mode value)
{
_cur_mode = value;
if (mode != nullptr)
Expand All @@ -164,7 +164,7 @@ namespace esphome
calc_and_publish_mode();
}

void publish_fanmode(FanMode value)
void update_fanmode(FanMode value)
{
if (climate != nullptr)
{
Expand All @@ -185,7 +185,7 @@ namespace esphome
}
}

void publish_altmode(AltMode value)
void update_altmode(AltMode value)
{
if (climate != nullptr)
{
Expand All @@ -204,7 +204,7 @@ namespace esphome
}
}

void publish_swing_vertical(bool value)
void update_swing_vertical(bool value)
{
if (climate != nullptr)
{
Expand All @@ -213,7 +213,7 @@ namespace esphome
}
}

void publish_swing_horizontal(bool value)
void update_swing_horizontal(bool value)
{
if (climate != nullptr)
{
Expand All @@ -222,13 +222,7 @@ namespace esphome
}
}

climate::ClimateSwingMode combine(climate::ClimateSwingMode climateSwingMode, uint8_t mask, bool value)
{
uint8_t swingMode = static_cast<uint8_t>(climateswingmode_to_swingmode(climateSwingMode));
return swingmode_to_climateswingmode(static_cast<SwingMode>(value ? (swingMode | mask) : (swingMode & ~mask)));
}

void publish_room_temperature(float value)
void update_room_temperature(float value)
{
if (room_temperature != nullptr)
room_temperature->publish_state(value);
Expand All @@ -239,7 +233,7 @@ namespace esphome
}
}

void publish_room_humidity(float value)
void update_room_humidity(float value)
{
if (room_humidity != nullptr)
room_humidity->publish_state(value);
Expand All @@ -254,6 +248,12 @@ namespace esphome
Protocol *protocol{nullptr};
MessageTarget *target{nullptr};

climate::ClimateSwingMode combine(climate::ClimateSwingMode climateSwingMode, uint8_t mask, bool value)
{
uint8_t swingMode = static_cast<uint8_t>(climateswingmode_to_swingmode(climateSwingMode));
return swingmode_to_climateswingmode(static_cast<SwingMode>(value ? (swingMode | mask) : (swingMode & ~mask)));
}

void calc_and_publish_mode()
{
if (!_cur_power.has_value())
Expand Down

0 comments on commit 5f86c77

Please sign in to comment.